Example - 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™

Field T1 in the table INTTIME is a TIME(6) value with the explicit format ' HH:MI:SSDS(6) '. Assume that you want to convert this to a value of CHAR(6), and an explicit output format of ' HHhMIm '.

SELECT T1 FROM INTTIME ;

The result (without a type change) is the following report:

             T1
---------------
05:57:11.362271

Now use nested CAST phrases and a FORMAT to obtain the desired result: a report in character format.

SELECT
CAST( (CAST (T1 AS FORMAT 'HHhMim'))
AS CHAR(6))
FROM INTTIME;

The result after the nested CASTs is the following report.

T1
------
05h57m

The inner CAST establishes the display format for the TIME value and the outer CAST indicates the data type of the desired result.