The FROM_TZ function converts the input timestamp and time zone information into the time of the time zone where the current database resides.
To use the FROM_TZ function, you must install the polar_from_tz
plug-in. Run the following command to install the plug-in:
CREATE EXTENSION polar_from_tz;
Syntax
from_tz(timestamp_value, time_zone_value)
Parameters
Parameter | Description |
---|---|
timestamp_value |
The timestamp, such as 2020-11-26 08:00:00 .
|
time_zone_value |
The time zone. The strings in the following formats are supported:
|
Examples
- If the value of
time_zone_value
is in the'TZH:TZM'
format, execute the following query statement:select from_tz('2020-11-26 08:00:00','+08:00') FROM dual;
The following query result is returned:
"2020-11-26 00:00:00+00"
- If the value of
time_zone_value
is in theTZR
format, execute the following query statement:select from_tz('2020-11-26 08:00:00','America/Los_Angeles') FROM dual;
The following query result is returned:
"2020-11-26 16:00:00+00"
- If the value of
time_zone_value
is in theTZD
format, execute the following query statement:select from_tz('2020-11-26 08:00:00','PST') FROM dual;
The following query result is returned:
"2020-11-26 16:00:00+00"