---
url: >-
  /statelake/scripting-reference/functions-and-procedures/datetime-functions/daysinmonth.md
---

# DaysInMonth

The function **DaysInMonth** returns the number of days in the month that has been specified by the given date.

**Declaration**: function DaysInMonth(const AValue: TDateTime): Word;

The following example shows several ways of achieving and displaying a result.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  vDIY : word;
  vDate : TDateTime;
  vStrDate : string;
begin
  vDIY := DaysInMonth(Date);
  LogInfo(IntToStr(vDIY));

 //JUNE - so 30 days
  vStrDate := '12-06-2022';
  vDate := StringToDateTime('dd/mm/yyyy',vStrDate);
  vDIY := DaysInMonth(vDate);
  LogInfo(IntToStr(vDIY));

 //March - so 31 days
  vStrDate := '08-03-2024';
  vDate := StringToDateTime('dd/mm/yyyy',vStrDate);
  vDIY := DaysInMonth(vDate);
  LogInfo(IntToStr(vDIY));

  LogInfo('');

end;
```
