CONVERT_TIMEZONE shifts a timestamp from one time zone to another in Snowflake.
Analytics often require aligning timestamps to a businessa0timea0zone. Using CONVERT_TIMEZONE lets you present dates in a usera0friendly zone without altering stored values.
Use three arguments: source zone, target zone, and timestamp. When the sessiona0timea0zone is the source, supply only target zone and timestamp.
Wrap the order_date
column in CONVERT_TIMEZONE('America/Los_Angeles', 'UTC', order_date)
. The result is a TIMESTAMP_TZ in UTC.
Yes. Use CREATE TABLE AS
or UPDATE
to persist the converted column, ensuring downstream queries always reference the correct zone.
Snowflake applies IANA rules automatically. CONVERT_TIMEZONE adjusts for DST, so 2024-03-10 02:30 PST becomes 10:30 UTC.
No. However, casting to TIMESTAMP_TZ
can avoid ambiguity. Use order_date::timestamp_tz
before conversion when data type is string.
Add both local and UTC columns in SELECTs. Developers can verify values side-by-side during migration.
Yes. Snowflake treats NTZ as seconds from epoch. It assumes the value is in the session time zone when converting.
Yes. Execute ALTER SESSION SET TIMEZONE = 'America/New_York';
. All TIMESTAMP_TZ outputs will then render in that zone without changing storage.
The function is deterministic and operates in-memory. Over millions of rows the cost is minimal compared to network I/O.