MinutesBetween
MinutesBetween returns the number of minutes between two specified TDateTime values.
Fractional or part minutes are not counted, so the function will return a whole integer value only.
For example, MinutesBetween reports the difference between 10:00 A.M. and 10:00:59:999 A.M. on the same day as zero (0) minutes between, because the minute stops a millisecond short of an entire minute.
The ordering of the two dates doesn't matter - the number of minutes will not be negative.
Declaration: Function MinutesBetween(const ANow, AThen: TDateTime): Int64;
A simple example follows.
procedure
OnMapEvent(
var
Value:Variant);
var
TheDate, ThatDate : TDateTime;
NumBetw :
integer
;
begin
//Result is 0 minutes
TheDate := EncodeDateTime(
2023
,
02
,
13
,
10
,
00
,
00
,
000
);
ThatDate := EncodeDateTime(
2023
,
02
,
13
,
10
,
00
,
59
,
999
);
NumBetw := MinutesBetween(TheDate,ThatDate);
LogInfo(
'The number of minutes between these dates is - '
+IntToStr(NumBetw));
//Result is 1 minute
ThatDate := EncodeDateTime(
2023
,
02
,
13
,
10
,
01
,
00
,
000
);
NumBetw := MinutesBetween(TheDate,ThatDate);
LogInfo(
'The number of minutes between these dates is - '
+IntToStr(NumBetw));
//Result is 60 minutes
ThatDate := EncodeDateTime(
2023
,
02
,
13
,
11
,
00
,
00
,
000
);
NumBetw := MinutesBetween(TheDate,ThatDate);
LogInfo(
'The number of minutes between these dates is - '
+IntToStr(NumBetw));
end
;