15.00 - Period-to-DATE Conversion - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

Period-to-DATE Conversion

Purpose

Converts Period data to a DATE value.

CAST Syntax

where:

 

Syntax element …

Specifies …

period_expression

the Period data expression to be cast to a DATE type.

date_data_attribute

one of the following optional data attributes:

  • FORMAT
  • NAMED
  • TITLE
  • ANSI Compliance

    This is ANSI SQL:2011 compliant.

    As an extension to ANSI, CAST permits the use of DATE data attribute phrases.

    Usage Notes

    A PERIOD(DATE) or PERIOD(TIMESTAMP(n) [WITH TIME ZONE]) value can be cast as DATE using the CAST function. The source last value must be equal to the source beginning bound; otherwise, an error is reported.

    If the source type is PERIOD(DATE), the result is the source beginning bound.

    If the source type is PERIOD(TIMESTAMP(n) [WITH TIME ZONE]), the result is the date portion of the source beginning bound after adjusting to the current session time zone.

    If the source type is PERIOD(TIME(n) [WITH TIME ZONE]), an error is reported.

    Example  

    Assume pd is a PERIOD(DATE) column in table t with a value of
    PERIOD '(2005-02-02, 2005-02-03)'.

    In the following example, a PERIOD(DATE) column is cast as DATE. The result is the beginning bound of the column.

       SELECT CAST(pd AS DATE) FROM t;

    The following is returned:

       2005-02-02

    Related Topics

    For details on data types and data attributes, see SQL Data Types and Literals.