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

# WithinPastMilliSeconds

**WithinPastMilliSeconds** indicates **True** if two **TDateTime** values are within the specified **AMilliSeconds** number of milliseconds of each other.

**WithinPastMilliSeconds** is used to determine whether the date specified by **ANow** is within **AMilliSeconds** milliseconds of the date specified by **AThen**.

**Declaration**: function WithinPastMilliSeconds(const ANow, AThen: TDateTime; const AMilliSeconds: Int64): Boolean;

A simple example follows.

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