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: |
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: |
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.