TIME-to-TIMESTAMP Conversion Example 12 - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Assume that the current date is DATE '2008-05-14' at time zone displacement, INTERVAL '09:00' HOUR TO MINUTE, but the current date is DATE '2008-05-13' at time zone displacement, INTERVAL -'08:00' HOUR TO MINUTE. The following SELECT statement returns the result: TIMESTAMP '2008-05-13 20:30:00-08:00'.

SET TIME ZONE INTERVAL '09:00' HOUR TO MINUTE;
SELECT CAST(TIME '08:30:00+04:00' AS TIMESTAMP(0) WITH TIME ZONE 
   AT -8);

The time zone displacement, INTERVAL '04:00' HOUR TO MINUTE, in the literal is used to determine the UTC value '04:30:00' and time zone displacement, INTERVAL '04:00' HOUR TO MINUTE, of the literal. For the CAST, the source expression value '04:30:00' at UTC is adjusted to the target time zone displacement, INTERVAL -'08:00' HOUR TO MINUTE, to yield '20:30:00'.

A timestamp is formed from the current date '2008-05-13' at time zone displacement, INTERVAL -'08:00' HOUR TO MINUTE, and the time portion of the source expression value '20:30:00' obtained after the preceding adjustment. Then this timestamp '2008-05-13 20:30:00' at time zone displacement, INTERVAL -'08:00' HOUR TO MINUTE, is adjusted to UTC so that the CAST result is '2008-05-14 04:30:00' at UTC with time zone displacement, INTERVAL -'08:00' HOUR TO MINUTE.

The result value of the CAST at UTC is adjusted to time zone displacement, INTERVAL -'08:00' HOUR TO MINUTE, so the result of the SELECT statement is: TIMESTAMP '2008-05-13 20:30:00-08:00'. The current session time zone has no effect.