IBM Support

SQL conversion of a timestamp to include a time zone

Question & Answer


Question

How do I convert a timestamp to a timestamp with a specific timezone in nzsql?

Answer

You can use the following SQL to convert time stamp values to timestamps with, for example, the Pacific Daylight Time time zone:

SELECT TIMESTAMP '2007-11-18 08:32:47' AT TIME ZONE 'PDT';

The resulting output is as follows:


 timezone 
------------------------
2007-11-18 01:32:47-07
(1 row)

Optionally, you can use the following SELECT statement:

SELECT TIMEZONE('PDT', column) FROM table;

The following example selects both the timezone and the original value for comparison:


select timezone('PDT',c1), c1 from t1;


       TIMEZONE        |         C1
------------------------+---------------------
 2010-07-09 06:07:34-07 | 2010-07-09 13:07:34
(1 row)

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Database","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

https://support.netezza.com/KB/Pages/NZ833416.aspx

Document Information

Modified date:
17 October 2019

UID

swg21560573