toDateTime toDateTime

Converts parameters into a date time value, depending on their types.

Category

Conversion

Function syntax

toDateTime(<parameters>)

Parameters

Parameter
Type
date time in ISO-8601 format
string
time zone id
string
date time without time zone
dateTimeOnly
integer value of an epoch in milliseconds
integer
NOTE
Time zone id must be a string constant. It cannot be a field reference nor an expression. For more information on data types, refer to this page.

Signatures and returned types

toDateTime(<string>)

toDateTime(<stringified time zone id>, <dateTimeOnly>)

toDateTime(<integer>)

Return a dateTime.

Examples

toDateTime ("2016-08-18T23:17:59.123Z")

Returns 2016-08-18T23:17:59.123Z

toDateTime(toDateTimeOnly("UTC", "2016-08-18T23:17:59.123"))

Returns 2016-08-18T23:17:59.123Z

toDateTime(1560762190189)

Returns 2019-06-17T09:03:10.189Z

recommendation-more-help
b22c9c5d-9208-48f4-b874-1cefb8df4d76