Tuesday, August 7, 2012

Notes on Teradata timestamp


IF the format of the Timestamp literal is …   THEN the data type is …
YYYY-MM-DD hh:mi:ss                               TIMESTAMP(0).
YYYY-MM-DD hh:mi:sssignhh:mi               TIMESTAMP(0) WITH TIME ZONE.
YYYY-MM-DD hh:mi:ss.ssssss                     TIMESTAMP(n), where n is the number of fractional
                                                                         seconds digits.
YYYY-MM-DD hh:mi:ss.sssssssignhh:mi     TIMESTAMP(n) WITH TIME ZONE, where n is the
                                                                         number of fractional seconds digits.




Example 1: YYYY-MM-DD hh:mi:ss Format
The following example selects all classes from the Classes table that are timestamped
November 23 2006 at 3:30:23 PM.
SELECT *
FROM Classes
WHERE Time_stamp = TIMESTAMP '2006-11-23 15:30:23';


Example 2: YYYY-MM-DD hh:mi:sssignhh:mi Format
SELECT *
FROM Classes
WHERE Time_stamp = TIMESTAMP '2002-01-01 10:37:12-08:00'


Example 3: YYYY-MM-DD hh:mi:ss.ssssss Format
SELECT *
FROM Classes
WHERE Time_stamp = TIMESTAMP '1995-07-31 10:36:02.123456'

Example 4: YYYY-MM-DD hh:mi:ss.sssssssignhh:mi Format
SELECT *
FROM Classes
WHERE Time_stamp = TIMESTAMP '1492-10-27 21:17:35.456123+07:30'

Source: Teradata documentation - SQL data types and literal

No comments:

Post a Comment