The EndOfTheYear function returns a TDateTime value that represents the last millisecond of the last day of the year, by returning the last expressible moment of the same year as the TDateTime value specified by AValue.

It replaces the time portion of AValue with 11:59:59.999 P.M., changes the day to 31 December, and returns the result.

Declaration: Function EndOfTheYear( const AValue : TDateTime) : TDateTime;

An example follows and with a processing date of 20/10/2023 10:20:18, returns 31/12/2023 23:59:59.999.

procedure OnMapEvent(var Value:Variant);
var
TheDate : TDateTime;
begin
TheDate := EndOfTheYear(Date);
LogInfo('The end of the year date is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));
end;