15.00 - INTERVAL-to-Character 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)

INTERVAL-to-Character Conversion

Purpose

Use CAST syntax or Teradata explicit conversion syntax to convert an INTERVAL type to its canonical character string representation.

INTERVAL-to-Character conversion is supported for CHAR and VARCHAR types only. The target type cannot be CLOB.

CAST Syntax

where:

 

Syntax element …

Specifies …

interval_expression

an INTERVAL expression to be converted.

character_data_type

the target character type to which the interval expression is to be converted.

character_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 character data attribute phrases.

    Teradata Conversion Syntax

    where:

     

    Syntax element …

    Specifies …

    interval_expression

    an INTERVAL expression to be converted.

    data_attribute

    one of the following optional data attributes:

  • FORMAT
  • NAMED
  • TITLE
  • character_data_type

    the target character type to which the interval expression is to be converted.

    server_character_set

    which server character set to use for the conversion.

    If the CHARACTER SET clause is omitted, the user default character set is used to convert the INTERVAL expression.

    ANSI Compliance

    This is a Teradata extension to the ANSI SQL:2011 standard.

    INTERVAL-to-Fixed CHARACTER Conversion

    When the target data type is CHAR(n), then n must be equal to or greater than the length of the canonical form of the value as represented by a character string literal.

    If n is greater than that length, trailing pad characters are added to pad the canonical representation.

    If n is too small, then a string truncation error is returned.

    INTERVAL-to-VARCHAR Conversion

    When the target data type is VARCHAR(n), then n must be equal to or greater than the length of the canonical form of the value as represented by a varying character string literal.

    If n is too small, then a string truncation error is returned.

    Related Topics

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