16.20 - Examples - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Functions, Expressions, and Predicates

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

Example 1: Requesting the Current Time by Session Time and Time Zone

If the DBS Control flag TimeDateWZControl is enabled, the following statements request the current time based on the current session time and time zone.

   SELECT TIME;
   SELECT TIME AT LOCAL;

The result is similar to:

    Time
--------
16:20:20

If the session time zone was defined with a time zone string that follows different DST and standard time zone displacements, then the time returned is automatically adjusted to account for the start and end of daylight saving time. Otherwise, no adjustment for daylight saving time is done.

Example 2: Returning the Current Time Based on Time Zone String, 'America Pacific'

The following queries return the current time at the time zone displacement based on the time zone string, 'America Pacific'. The time returned is automatically adjusted to account for the start and end of daylight saving time.

   SELECT TIME AT TIME ZONE 'America Pacific';
   SELECT TIME AT 'America Pacific';

Example 3: Displaying Hundredths of a Second

The hundredths of a second are not displayed by the default format, but you can use the FORMAT phrase to display it:

   SELECT TIME (FORMAT '99:99:99.99');

The system responds with something like the following:

       Time
-----------
16:26:30.19

Example 4: Inserting a Row in a Table

The following example inserts a row in a hypothetical table in which the column InsertTime has data type FLOAT and records the time that the row was inserted:

   INSERT INTO HypoTable (ColumnA, ColumnB, InsertTime) 
   VALUES ('Abcde', 12345, TIME);