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

# MilliSecondsBetween

**MilliSecondsBetween** returns the number of milliseconds between two specified **TDateTime** values.

The ordering of the two dates doesn't matter - the number of seconds will not be negative.

**Declaration**: Function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;

A simple example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  TheDate, ThatDate : TDateTime;
  NumBetw : integer;
begin
 //Result is 999 milliseconds
  TheDate := EncodeDateTime(2023, 02, 13, 10, 00, 00, 000);
  ThatDate := EncodeDateTime(2023, 02, 13, 10, 00, 00, 999);
  NumBetw := MilliSecondsBetween(TheDate,ThatDate);
  LogInfo('The number of milliseconds between these dates is - '+IntToStr(NumBetw));
end;
```
