Character Strings That Omit Hour, Minute, or Second - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
zsn1556242031050.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantage™

If the character string in a character-to-TIME conversion omits the hour, minute, or second, the system uses default values for the target TIME value.

IF the character string omits the … THEN the system uses the …
hour value of 0.
minute
second

Consider the following table:

CREATE TABLE time_log
   (id INTEGER 
   ,start_time TIME 
   ,end_time TIME
   ,log_time TIME);

The following INSERT statement converts three character strings to TIME values. The first character string omits the hour, the second character string omits the minute, and the third character string omits the second.

INSERT time_log
   (1001
   ,CAST ('01:02.030405' AS TIME FORMAT 'MI:SS.S(6)')
   ,CAST ('01:02.030405' AS TIME FORMAT 'HH:SS.S(6)')
   ,CAST ('01:02' AS TIME FORMAT 'HH:MI'));

The result of the INSERT statement is as follows:

SELECT * FROM time_log;
         id       start_time         end_time         log_time
-----------  ---------------  ---------------  ---------------
       1001  00:01:02.030405  01:00:02.030405  01:02:00.000000