The EndOfADay function returns a TDateTime date value that represents the last millisecond of a specified day.

EndOfADay returns the last expressible moment of the day specified by ADay by replacing the time portion with 23:59:59.

  • The AYear parameter specifies the year of the desired day.

  • The AMonth and ADay parameters specify the desired day as a month of the year and day of the month. AMonth can range from 1 through 12, while ADay can range from 1 through 28, 29, 30, or 31, depending on the values of AYear and AMonth.

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

An example follows.

procedure OnMapEvent(var Value:Variant);
var
TheDate : TDateTime;
TheYear, TheMonth, TheDay : Word;
begin
//Result is 03/10/2023 23:59:59
TheYear := 2023;
TheMonth := 10;
TheDay := 3;
TheDate := EndOfADay(TheYear, TheMonth, TheDay);
LogInfo('The end of the day 3rd October 2023 is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));
end;