Examples | TIME-to-TIMESTAMP Conversion | Teradata Vantage - 17.10 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

Assuming the current date is DATE '2008-05-14' at time zone displacement, INTERVAL '09:00' HOUR TO MINUTE, the following SELECT statements return the result: TIMESTAMP '2008-05-14 08:30:00'.

SET TIME ZONE INTERVAL '09:00' HOUR TO MINUTE;
SELECT CAST(TIME '08:30:00' AS TIMESTAMP(0));
SELECT CAST(TIME '08:30:00' AS TIMESTAMP(0) AT LOCAL);

The current session time zone displacement, INTERVAL '09:00' HOUR TO MINUTE, is used to determine the UTC value '23:30:00' of the literal.

For the CAST, the source expression value '23:30:00' at UTC is adjusted to the current session time zone displacement, INTERVAL '09:00' TO MINUTE, to yield '08:30:00'. A timestamp is formed from the current date '2008-05-14' at time zone displacement, INTERVAL '09:00' HOUR TO MINUTE, and the time portion of the source expression value '08:30:00'. Then, this timestamp, '2008-05-14 08:30:00', at time zone displacement, INTERVAL '09:00' HOUR TO MINUTE, is adjusted to UTC so that the CAST result is '2008-05-13 23:30:00' at UTC.

The result value of the CAST at UTC is adjusted to the current session time zone displacement, INTERVAL '09:00' HOUR TO MINUTE, so the result of the SELECT statements is: TIMESTAMP '2008-05-14 08:30:00'.