---
url: >-
  /statelake/scripting-reference/functions-and-procedures/conversion-functions/stringtodatetime.md
---

# StringToDateTime

**StringToDateTime** will return a **TDateTime** value, built from the **DateTimeStr** value that is passed in.

**DateTimeFormat** describes the format of **DateTimeStr** - please refer to [Date And Time Format Specifiers](/statelake/scripting-reference/functions-and-procedures/formatting-functions/format-specifiers/date-and-time-format-specifiers) for help creating the **DateTimeFormat** parameter.

Declaration: Function StringtoDateTime( const DateTimeFormat : string; const DateTimeStr : string) : TDateTime

This example shows the date as a string variable, being converted into two (2) **TDateTime** formats.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  MyStrDate : string;

begin
  MyStrDate := '23/02/2026';
 //Value will be equal to a TDateTime of 23/02/2026
  Value := StringToDateTime('dd/mm/yyyy',MyStrDate);

 //Value will be equal to a TDateTime of 2026-02-23
  Value := StringToDateTime('yy-mm-dd',MyStrDate);

end;
```

A reference to this function can also be found under **DateTime Functions** at [StringToDateTime (Conversion)](/statelake/scripting-reference/functions-and-procedures/datetime-functions/stringtodatetime-datetime).
