WithinPastWeeks indicates True if two TDateTime values are within the specified AWeeks number of weeks of each other.

WithinPastWeeks is used to determine whether the date specified by ANow is within AWeeks weeks of the date specified by AThen.

Fractional weeks do not count, so if ANow and AThen are two and a half weeks apart, calling WithinPastWeeks with AWeeks set to 2, returns True.

Declaration: function WithinPastWeeks(const ANow, AThen: TDateTime; const AWeeks: Integer): Boolean;

An example follows.

procedure OnMapEvent(var Value:Variant);
var
TheDate, ThatDate : TDateTime;
begin
//The IF is False as more than 2 weeks
TheDate := EncodeDateTime(2023, 11, 30, 13, 25, 15, 650);
ThatDate := EncodeDateTime(2023, 10, 29, 13, 25, 15, 650);
If WithinPastWeeks(ThatDate, TheDate, 2) then
LogInfo('The difference between the two dates is less than 2 weeks')
else
LogInfo('The difference between the two dates is more than 2 weeks');
end;