Usage Notes | CAST in Explicit Data Type Conversions | Teradata Vantage - Usage Notes - Teradata Vantage - Analytics Database

SQL Data Types and Literals

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
uds1628112204571.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
exs1472253032394
lifecycle
latest
Product Category
Teradata Vantage™

The ANSI SQL:2011 compliant form can be used to convert data types in either ANSI-compliant SQL statements or Teradata SQL statements.

The Teradata extended syntax is more general. It allows a type declaration or data attributes or both.

Avoid using the extended form of CAST for any application intended to be ANSI-compliant and portable.

CAST functions identically in both ANSI and Teradata modes.

When converting DateTime data types, you can use the AT clause to specify the time zone used for the CAST. You can specify the source time zone, a specific time zone displacement, or the current session time zone. For more information, see the section on converting the specific data type, for example, TIMESTAMP-to-DATE Conversion.

CAST does not convert the following data type pairs:
  • Numeric to character, if the server character set is GRAPHIC.
  • Character expressions having different server character sets.

    To make such a conversion, use the TRANSLATE function. For more information, see Teradata Vantage™ - SQL Functions, Expressions, and Predicates, B035-1145.

  • Byte (BYTE, VARBYTE, and BLOB) to any data type other than UDT or byte, and data types other than byte or UDT to byte.
  • CLOB to any data type other than UDT or character, and data types other than character or UDT to CLOB.

For information on casting to and from geospatial types, see Teradata Vantage™ - Geospatial Data Types, B035-1181.

Data type conversions involving UDTs require appropriate cast definitions for the UDTs. To define a cast for a UDT, use the CREATE CAST statement.