Outdated Version

You are viewing an older version of this section. View current production version.

CONVERT_TZ

Converts a given datetime object from one timezone to another.

CONVERT_TZ (dateobj, oldtz, newtz)

Arguments

  • dateobj: a valid date, datetime, or parsable date string
  • oldtz, newtz: any valid timezone identifier.
Info

Timezone identifiers may be explicit intervals or named zones. Explicit intervals are in the form +10:00 or -3:30 and are counted from UTC. Named timezones are in the form America/Mazatlan or EST. The list of supported timezone names are dependent on the tz database installed on your system.

Return Type

Date or datetime object. If dateobj, oldtz, or newtz is not valid, returns NULL.

Examples

memsql> SELECT CONVERT_TZ('2014-04-18 12:00:00','GMT','EST');
+-----------------------------------------------+
| CONVERT_TZ('2014-04-18 12:00:00','GMT','EST') |
+-----------------------------------------------+
| 2014-04-18 07:00:00                           |
+-----------------------------------------------+

memsql> SELECT CONVERT_TZ('2014-04-18 12:00:00','GMT','-3:14');
+-------------------------------------------------+
| CONVERT_TZ('2014-04-18 12:00:00','GMT','-3:14') |
+-------------------------------------------------+
| 2014-04-18 08:46:00                             |
+-------------------------------------------------+