Skip to Content

mvSQL Database Function - FROMTIMEZONE()

Summary

Adjusts a date and time at the given time zone offset to UTC.

Syntax

FROMTIMEZONE(<datetime>, <timezoneoffset>)

Parameters

datetime

An expression that resolves to a datetime value. The datetime value is assumed to be in the given time zone offset.

timezoneoffset

A string in the ISO offset format ±[hh]:[mm].

Returns

Returns a datetime adjusted from the given time zone to UTC.

The datetime data type stores a timestamp without a time zone offset.

Remarks

The FROMTIMEZONE() function is only supported on RDBMS data providers. The following data providers have been tested:

  • DB2/LUW
  • DB2/i
  • MySQL
  • Oracle
  • PostgreSQL
  • SQL Server
  • SQLite

Examples

Literal Time Zone Offset

Given:

  • NOW() evaluates to 2018-08-01 17:00:00.000

The expression:

FROMTIMEZONE(NOW(), '-04:00')

Returns 2018-08-01 21:00:00.000

Client Time Zone Offset

Given:

  • NOW() evaluates to 2018-08-01 17:00:00.000
  • CLIENT(TIMEZONEOFFSET) evaluates to '-04:00'

The expression:

FROMTIMEZONE(NOW(), CLIENT(TIMEZONEOFFSET))

Returns 2018-08-01 21:00:00.000