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

# SameDateTime

**SameDateTime** compares two **TDateTime** values **A** and **B**, to test whether they represent the same year, month, day, hour, minute, second, and millisecond.

**SameDateTime** returns **True** if the two specified values represent the same date and time, and returns **False** if they are not the same.

It is possible to create two **TDateTime** values that differ numerically when viewed as floating point types, but which represent the same year, month, day, hour, minute, second, and millisecond.

**SameDateTime** allows applications to determine when two **TDateTime** values are the same even when their numeric values differ.

**Declaration**: function SameDateTime(const A, B: TDateTime): Boolean;

A simple example showing a passed test and a failed test follows.

```pascal
procedure ScriptEvent (var Value : variant);
var
  DateTime1, DateTime2 : TDateTime;
  Counter : integer;
begin
 //These will be the same
  DateTime1 := Now;
  DateTime2 :=  Now;
 If SameDateTime(DateTime1, DateTime2) then
    LogInfo('They are the same date and time!')
 else
    LogInfo('They are NOT the same date and time!');

  Counter := 1;
 while Counter < 500 do
 begin
    Counter := Counter + 1;
 end;
 //These will not be the same
  DateTime2 :=  Now;
 If SameDateTime(DateTime1, DateTime2) then
    LogInfo('They are the same date and time!')
 else
    LogInfo('They are NOT the same date and time!');

end;
```
