16.20.16.20 - 16.20 - Examples - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ Data Types and Literals

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

The following examples illustrate how to perform data type conversions using CAST.

Example: Performing Data Type Conversions

Using ANSI CAST syntax:

SELECT ID_Col, Name_Col
FROM T1
WHERE Int_Col = CAST(SUBSTRING(Char_Col FROM 3 FOR 3) AS INTEGER);

Example: Performing Data Type Conversions Using ANSI CAST Syntax

Using ANSI CAST syntax:

SELECT CAST(SUBSTRING(Char_Col FROM 1 FOR 2) AS INTEGER),
   CAST(SUBSTRING (Char_Col FROM 3 FOR 3) AS INTEGER) 
FROM T1;

Example: Performing Data Type Conversions Using Teradata Extensions to the ANSI CAST Syntax

Using Teradata extensions to the ANSI CAST syntax:

CREATE TABLE t2 (f1 TIME(0) FORMAT 'HHhMIm');
   
INSERT t2 (CAST('15h33m' AS TIME(0) FORMAT 'HHhMIm'));
   
SELECT f1 FROM t2;

The result from the SELECT statement is:

    f1
------
15h33m