Check whether two TDateTimes are only a number of weeks apart.
Source position: dateutil.inc line 267
function WithinPastWeeks( |
const ANow: TDateTime; |
const AThen: TDateTime; |
const AWeeks: Integer |
):Boolean; |
ANow |
|
First moment in time. |
AThen |
|
Second moment in time. |
AWeeks |
|
Number of weeks to check. |
True if ANow and Athen are only AWeeks apart, false otherwise.
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 |
|
Check whether two TDateTimes are only a number of years apart. |
|
|
Check whether two TDateTimes are only a number of months apart. |
|
|
Check whether two TDateTimes are only a number of days apart. |
|
|
Check whether two TDateTimes are only a number of hours apart. |
|
|
Check whether two TDateTimes are only a number of minutes apart. |
|
|
Check whether two TDateTimes are only a number of seconds apart. |
|
|
Check whether two TDateTimes are only a number of milliseconds apart. |
Program Example49; { This program demonstrates the WithinPastWeeks function } Uses SysUtils,DateUtils; Procedure Test(ANow,ThenDateTime; AWeeks : Integer); begin Write(DateToStr(Thenand ',DateToStr(ANow)); Write(' are within ',AWeeks,' weeks: '); Writeln(WithinPastWeeks(ANow,Theneks)); 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.