TIME Function Examples | Teradata Vantage - 17.10 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
kby1472250656485

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);