MySQL Tutorial/Date Time Functions/CONVERT TZ

Материал из SQL эксперт
Перейти к: навигация, поиск

CONVERT_TZ(dt,from_tz,to_tz)

CONVERT_TZ() converts a datetime value dt from the time zone given by from_tz to the time zone given by to_tz and returns the resulting value.

CONVERT_TZ() returns NULL if the arguments are invalid.



mysql>
mysql> SELECT CONVERT_TZ("2004-01-01 12:00:00","GMT","MET");
+-----------------------------------------------+
| CONVERT_TZ("2004-01-01 12:00:00","GMT","MET") |
+-----------------------------------------------+
| NULL                                          |
+-----------------------------------------------+
1 row in set (0.02 sec)


SELECT CONVERT_TZ("2004-00:00","+00:00","+10:00");

mysql>
mysql>
mysql>
mysql> SELECT CONVERT_TZ("2004-01-01 12:00:00","+00:00","+10:00");
+-----------------------------------------------------+
| CONVERT_TZ("2004-01-01 12:00:00","+00:00","+10:00") |
+-----------------------------------------------------+
| 2004-01-01 22:00:00                                 |
+-----------------------------------------------------+
1 row in set (0.00 sec)
mysql>