WithinPastWeeks
Check whether two TDateTimes are only a number of weeks apart
Declaration
Source position: dateutil.inc line 245
function WithinPastWeeks(const ANow: TDateTime; const AThen: TDateTime;
const AWeeks: Integer) : Boolean;
Description
WithinPastWeeks compares the timestamps ANow and AThen and returns True if the difference between them is at most AWeeks weeks apart, or False if they are further apart.
Remark
Since this function uses the WeeksBetween function to calculate the difference in Weeks, this means that fractional Weeks do not count, and the fractional part is simply dropped, so for two dates actually 2 and a half weeks apart, the result will also be True !!!
See also
Name | Description |
---|---|
WithinPastDays | Check whether two TDateTimes are only a number of days apart |
WithinPastHours | Check whether two TDateTimes are only a number of hours apart |
WithinPastMilliSeconds | Check whether two TDateTimes are only a number of milliseconds apart |
WithinPastMinutes | Check whether two TDateTimes are only a number of minutes apart |
WithinPastMonths | Check whether two TDateTimes are only a number of months apart |
WithinPastSeconds | Check whether two TDateTimes are only a number of seconds apart |
WithinPastYears | Check whether two TDateTimes are only a number of years apart |
Example
Program Example49;
{ This program demonstrates the WithinPastWeeks function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AWeeks : Integer);
begin
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Write(' are within ',AWeeks,' weeks: ');
Writeln(WithinPastWeeks(ANow,AThen,AWeeks));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-7;
Test(D1,D2,1);
D2:=Today-8;
Test(D1,D2,1);
D2:=Today-14;
Test(D1,D2,1);
D2:=Today-35;
Test(D1,D2,5);
D2:=Today-36;
Test(D1,D2,5);
D2:=Today-17;
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.