Reference/Functions/
AT_TIME_ZONE
The date function used to convert a date or date time value to a given time zone. Takes two arguments,
the date to be converted and the timezone. Time zones can be specified either via three-letter code
("UTC", "CST") or via offset ("-6:00"). If the date or datetime value has no specified time zone,
this function simply applies the specified timezone to the specified time. If the date or datetime
value already has a specified time zone, the specified time will be converted to the value of that
time in the time zone parameter.
Parameter | Type |
---|
dateValue | datetime, date, time, datetimestamp, gyear, gyearmonth |
timezone | string |
Returns: date
Example
query:
SELECT AT_TIME_ZONE(CAST("2018-01-02" AS DATE), "-6:00")
results:
at_time_zone |
2018-01-02-06:00 |
query:
SELECT AT_TIME_ZONE(CAST("2018-01-02" AS DATE), "EST")
results:
at_time_zone |
2018-01-02-05:00 |
query:
SELECT AT_TIME_ZONE(CAST("2018-01-02T10:41:26" AS DATETIME), "-6:00")
results:
at_time_zone |
2018-01-02T10:41:26-06:00 |