# TO_DATETIME

The TO_DATETIME function converts an input value into a date value.

## Syntax

`TO_DATETIME(field)`

### Parameters

#### field

The input value to be converted, either single or multi-valued column or an expression.
If of type string, the input must follow the `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` format. To convert strings in other formats, use DATE_PARSE.

## Examples

The following example converts a string into a date value:

```esql
ROW string = ["1953-09-02T00:00:00.000Z", "1964-06-02T00:00:00.000Z", "1964-06-02 00:00:00"]
| EVAL datetime = TO_DATETIME(string)
```

If the input parameter is of a numeric type, its value will be interpreted as milliseconds since the Unix epoch. For example:

```esql
ROW int = [0, 1]
| EVAL dt = TO_DATETIME(int)
```

## Notes

- Can only convert string with the exact format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. To convert dates in other formats, use the `DATE_PARSE` function.

- When converting from nanosecond resolution to millisecond resolution with this function, the nanosecond date is truncated, not rounded.
