Date and Time Literals | Data Types and Literals | Teradata Vantage - Date and Time Literals - 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™

Date and time literals declare date, time, or timestamp values in an SQL expression.

ANSI DateTime Literals

ANSI SQL provides DateTime literals to represent date, time, and timestamp values. There are three types of ANSI SQL DateTime literals:
  • DATE
  • TIME
  • TIMESTAMP

Teradata SQL Date and Time Literals

Teradata also provides a non-ANSI extension to DateTime functionality.

Teradata SQL literals used with date or time values are simple string literals and are interpreted as character data. These are converted to a date or time value based on the context, which is usually provided by a FORMAT clause.

The existing Teradata SQL operations on character string literals used to represent date and time values are supported as a non-ANSI extension to DateTime functionality.

While Teradata SQL date and time literals come in a variety of formats for the character representations of date and time values, and so cannot be restricted to a default or standard format, ANSI DateTime literals are restricted to a strict set of formats.

Existing functionality for Teradata SQL date literals is preserved.

For example, suppose a column is defined as DATE with a format of ' YY/MM/DD '. If the value ' 97/12/31 ' is encountered as a character literal assigned to a DATE column, the process works just as it did prior to the introduction of ANSI DateTime formats because the character literal is implicitly cast to the DATE format.

Unless explicitly stated, this section only discusses ANSI DateTime literals.