---
url: >-
  /statelake/scripting-reference/functions-and-procedures/formatting-functions/formatdatetime-formatting.md
---

# FormatDateTime (Formatting)

The **FormatDateTime** function converts a **DateTime** value into a **String** data type, using a provided date and time format specifier **Format** - see [Date And Time Format Specifiers](/statelake/scripting-reference/functions-and-procedures/formatting-functions/format-specifiers/date-and-time-format-specifiers).

This is commonly used when you need to build a **String** and concatenate a **Datetime** value.

For a more in-depth explanation of this function, please refer to [FormatDateTime](/statelake/scripting-reference/functions-and-procedures/conversion-functions/formatdatetime).

**Declaration**: Function FormatDateTime(const Format : string; DateTime : TDateTime) : string

A simple example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var MyDate : TDateTime
begin
  MyDate := Now;
  Value := FormatDateTime('dd/mm/yyyy hh:nn',MyDate);
end;
```
