## TO_DATETIME

The `TO_DATETIME` function converts an input value to a date value. A string will only be successfully converted if it’s respecting the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. To convert dates in other formats, use `DATE_PARSE`.

### Examples

Here are a couple of examples of how to use the `TO_DATETIME` function in ES|QL queries:

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

In this example, the last value in the source multi-valued field has not been converted. This is because if the date format is not respected, the conversion will result in a null value. When this happens a Warning header is added to the response. The header will provide information on the source of the failure.

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

In this example, if the input parameter is of a numeric type, its value will be interpreted as milliseconds since the Unix epoch.