---
url: >-
  /statelake/scripting-reference/functions-and-procedures/datetime-functions/withinpastminutes.md
---

# WithinPastMinutes

**WithinPastMinutes** indicates **True** if two **TDateTime** values are within the specified **AMinutes** number of minutes of each other.

**WithinPastMinutes** is used to determine whether the date specified by **ANow** is within **AMinutes** minutes of the date specified by **AThen**.

Fractional minutes do not count, so if **ANow** and **AThen** are two and a half minutes apart, calling **WithinPastMinutes** with **AMinutes** set to 2, returns **True**.

**Declaration**: function WithinPastMinutes(const ANow, AThen: TDateTime; const AMinutes: Int64): Boolean;

An example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  TheDate, ThatDate : TDateTime;
begin
 //The IF is True as less than or equal to 5 minutes
  TheDate := EncodeDateTime(2023, 11, 30, 13, 25, 15, 650);
  ThatDate := EncodeDateTime(2023, 11, 30, 13, 28, 15, 700);
 If WithinPastMinutes(ThatDate, TheDate, 5) then
    LogInfo('The difference between the two dates is less than 5 minutes.')
 else
    LogInfo('The difference between the two dates is more than 5 minutes.');
end;
```
