Description
Converts an inputdate to the corresponding datetimeoffset value in the target time zone. (AT TIME ZONE in Transact-SQL ).
Sample Source Pattern
Syntax
SQL Server Snowflake SQL
Copy inputdate AT TIME ZONE timezone
Snowflake SQL Documentation
Copy CONVERT_TIMEZONE( <source_tz> , <target_tz> , <source_timestamp_ntz> )
CONVERT_TIMEZONE( <target_tz> , <source_timestamp> )
Examples
SQL Server Snowflake SQL
Copy SELECT CAST('2022-11-24 11:00:45.2000000 +00:00' as datetimeoffset) at time zone 'Alaskan Standard Time';
Result:
Copy DATE|
------------------------------+
2022-11-24 02:00:45.200 -09:00|
Copy SELECT
CONVERT_TIMEZONE('America/Anchorage', CAST('2022-11-24 11:00:45.2000000 +00:00' as TIMESTAMP_TZ(7)));
Result:
Copy DATE|
------------------------------+
2022-11-24 02:00:45.200 -09:00|
SQL Server Snowflake SQL
Code:
Copy SELECT current_timestamp at time zone 'Central America Standard Time';
Result:
Copy DATE|
------------------------------+
2022-10-10 10:55:50.090 -06:00|
Code:
Copy SELECT
CONVERT_TIMEZONE('America/Costa_Rica', CURRENT_TIMESTAMP() !!!RESOLVE EWI!!! /*** SSC-EWI-TS0070 - CURRENT_TIMESTAMP in At Time Zone statement may have a different behavior in certain cases ***/!!!);
Result:
Copy DATE|
------------------------------+
2022-10-10 10:55:50.090 -06:00|
Known Issues
Snowflake does not support all the time zones that SQL Server does. You can check the supported time zones at this link .
SQL Server Snowflake SQL
Copy SELECT current_timestamp at time zone 'Turks And Caicos Standard Time';
Result:
Copy DATE|
------------------------------+
2022-12-14 20:04:18.317 -05:00|
Copy SELECT
!!!RESOLVE EWI!!! /*** SSC-EWI-TS0063 - TIME ZONE NOT SUPPORTED IN SNOWFLAKE ***/!!!
CURRENT_TIMESTAMP() at time zone 'Turks And Caicos Standard Time';
Related EWIs