TIME Function Examples | Teradata Vantage - Examples - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

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