---
url: /flow/guide/scripting-reference/functions/datetime/isvaliddatetime.md
---

# IsValidDateTime

## Declaration

`function IsValidDateTime(const AYear: Word; const AMonth: Word; const ADay: Word; const AHour: Word; const AMinute: Word; const ASecond: Word; const AMilliSecond: Word): Boolean;`

### Example

```pascal
procedure OnMapEvent(var Value:Variant);
begin
  Value := IsValidDateTime(2009, 06, 25, 15, 45, 23, 562); //returns true if the given date and time parts would create a valid date and time
end;
```

## Description

Returns True if the given date and time parts would return a valid date and time. Useful for testing Date parts prior to passing them to the [EncodeDateTime](/flow/guide/scripting-reference/functions/datetime/encodedatetime) function.
