# TO_DATETIME

The TO_DATETIME function converts an input value to a date value. Strings are only converted successfully if they match the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. For other date formats, use the `DATE_PARSE` function. When converting from nanosecond to millisecond resolution, the nanosecond date is truncated, not rounded.

## Syntax

`TO_DATETIME(field)`

### Parameters

#### field

The input value to convert. This can be a single- or multi-valued column, or an expression.

## Examples

Converts each string in a multi-valued column to a datetime, returning `null` for strings that do not match the required format.

```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)
```

Converts integer values representing milliseconds since the Unix epoch to datetime values.

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

## Limitations

- Only strings matching the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` are converted; others result in `null`.
- When converting from nanosecond to millisecond resolution, the value is truncated, not rounded.