DayOfTheWeek returns the day of the week represented by the TDateTime value specified by AValue.

You would use this function DayOfTheWeek to obtain the ordinal position of day within its week, where 1 indicates a Monday, and 7 indicates a Sunday.

DayOfTheWeek is ISO 8601 compliant, where Monday is considered the first day of the week.

To obtain the day of the week, where Sunday is considered the first day of the week, use the DayOfWeek function instead. Please review DayOfWeek.

Declaration: function DayOfTheWeek(const AValue: TDateTime): Word;

A code example follows.

procedure OnMapEvent(var Value:Variant);
var
TheDay : word;
begin
//If YESTERDAY is 29-11-2023 then the result is 3 (Wednesday)
TheDay := DayOfTheWeek(Yesterday);
LogInfo('The day number for Wednesday 29-11-2023 is '+IntToStr(TheDay));
end;