Skip to content

EndOfAMonth ​

EndOfAMonth returns a TDateTime value that represents the last millisecond of the last day of the month and year, by returning the last expressible moment of the month specified by AMonth and the year specified by AYear.

Declaration: Function EndOfAMonth(const AYear, AMonth : Word) : TDateTime;

An example follows and with a processing year of 2023 and month of 7, the function returns 31/07/2023 23:59:59.

pascal
procedure OnMapEvent(var Value:Variant);
var
  TheYear, TheMonth : word;
  TheDate : TDateTime;
begin
 TheYear := 2023;
 TheMonth := 7;
 TheDate := EndOfAMonth(TheYear, TheMonth);
 LogInfo('The end of the month date is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));
end;