The EndOfTheWeek function returns a TDateTime date value that represents the last millisecond of the last day of the week identified by a specified TDateTime value.
EndOfTheWeek returns the last expressible moment of the week specified by AValue, by replacing the time portion of AValue with 23:59:59, and changing the day to Sunday.
The function defines the week of AValue according to the ISO 8601 standard, where the week starts on Monday and ends on Sunday.
Declaration: Function EndOfTheWeek(const AValue: TDateTime): TDateTime;
An example follows.
procedure OnMapEvent(var Value:Variant);
var
TheDate : TDateTime;
begin
//Processing date is 29/11/2023, so the return value is 03/12/2023 23:59:59
TheDate := EndOfTheWeek(Date);
LogInfo('The end of the week date is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));