CONVERT_TZ

2023-10-31 11:17:12  Updated

Syntax

CONVERT_TZ(dt,from_tz,to_tz)

Purpose

CONVERT_TZ() converts the datetime value specified by dt from the time zone specified by from_tz to the time zone specified by to_tz and returns the result. It returns NULL if the dt argument is invalid.

If the value obtained by converting the datetime value from the time zone specified by from_tz to the UTC time exceeds the value range of TIMESTAMP, the conversion is aborted. For more information about the value range of the TIMESTAMP type, see DATE, DATETIME, and TIMESTAMP types.

Examples

obclient> SELECT CONVERT_TZ('2014-01-01 12:00:00','+00:00','+8:00');
+----------------------------------------------------+
| CONVERT_TZ('2014-01-01 12:00:00','+00:00','+8:00') |
+----------------------------------------------------+
| 2014-01-01 20:00:00                                |
+----------------------------------------------------+
1 row in set

Contact Us