Todatetime
todatetime
Converts a scalar value to a UTC datetime. Invalid values return null.
Spec
todatetime(value)Parameters
value: A scalar expression. Strings are parsed, datetime values pass through, and JSON strings are unwrapped and parsed. Nulls and values that cannot be converted return null. Numeric inputs are not Unix timestamps; convert epoch values explicitly using datetime arithmetic.
Dates without a timezone use UTC. Explicit offsets are normalized to UTC. Parsing is independent of the server's culture and timezone and retains up to seven fractional second digits (100 ns precision).
Use ISO 8601 strings such as 2024-06-15, 2024-06-15T14:30, or 2024-06-15T14:30:00.1234567Z. Space-separated dates and times, RFC 822/RFC 850 dates (including English weekday/month names and GMT), and US month/day/year dates are also accepted. A complete date is required. For constant dates, prefer a datetime(...) literal.
Return Value
A datetime, or null when conversion fails (including an empty string, invalid calendar date, or out-of-range value).
Example
datatable(value:string)[
'2024-06-15T16:30:00+02:00',
'2024-06-15',
'invalid'
]
| project timestamp = todatetime(value)| timestamp |
|---|
| 2024-06-15T14:30:00.0000000Z |
| 2024-06-15T00:00:00.0000000Z |
| null |
See also format_datetime and the Kusto reference.