CONVERT_TIMEZONE
functionsupportedCore SQL functionsConverts a timestamp to another time zone.
Syntax
CONVERT_TIMEZONE( <source_tz> , <target_tz> , <source_timestamp_ntz> )
CONVERT_TIMEZONE( <target_tz> , <source_timestamp> )
Parameters
| Name | Required | Description |
|---|---|---|
source_tz | required | String specifying the time zone for the input timestamp. Required for timestamps with no time zone (that is, TIMESTAMP_NTZ). |
target_tz | required | String specifying the time zone to which the input timestamp is converted. |
source_timestamp_ntz | required | For the 3-argument version, string specifying the timestamp to convert (must be TIMESTAMP_NTZ). |
source_timestamp | required | For the 2-argument version, the timestamp to convert. Can be any timestamp variant (TIMESTAMP_LTZ, TIMESTAMP_NTZ, or TIMESTAMP_TZ) or a DATE value. For how the source time zone is determined for each of these types, see the usage notes below. |
Returns
Returns a value of type TIMESTAMP_NTZ, TIMESTAMP_TZ, or NULL: - For the 3-argument version, returns a value of type TIMESTAMP_NTZ. - For the 2-argument version, returns a value of type TIMESTAMP_TZ. - If any argument is NULL, returns NULL.
Usage notes
- The display format for timestamps in the output is determined by the timestamp output format for the current session and the data type of the returned timestamp value.
- For the 3-argument version, the “wallclock” time in the result represents the same moment in time as the input “wallclock” in the input time zone, but in the target time zone.
- For the 2-argument version, the source time zone is determined by the data type of the source_timestamp argument: TIMESTAMP_TZ: The time zone is taken from the value itself.
- TIMESTAMP_LTZ: The time zone is the current session time zone (set by the TIMEZONE parameter).
- TIMESTAMP_NTZ: The value has no time zone, so it’s interpreted as a “wallclock” time in the current session time zone, and that session time zone is used as the source.
- DATE: The value is cast to TIMESTAMP_NTZ with the time set to midnight (00:00:00), and then handled the same way as TIMESTAMP_NTZ (the current session time zone is used as the source).
- For source_tz and target_tz, you can specify a time zone name or a link name from the currently active IANA Time Zone Database release (for example, America/Los_Angeles, Europe/London, UTC, Etc/GMT, and so on). To determine that release, call the SYSTEM$GET_TZDB_VERSION function. Note Time zone names are case-sensitive and must be enclosed in single quotes (e.g. 'UTC').
- Snowflake does not support the majority of timezone abbreviations (e.g. PDT, EST, etc.) because a given abbreviation might refer to one of several different time zones. For example, CST might refer to Central Standard Time in North America (UTC-6), Cuba Standard Time (UTC-5), and China Standard Time (UTC+8).