Example: DATE-to-Numeric Conversion - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
zsn1556242031050.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following example converts DATE data in the dob column of the employee table to a numeric format.

Note that the best practice is to define date data as a DATE type; do not define date data as a numeric type.

To change the display from date format to integer format, change the statement to:

SELECT name, dob (INTEGER) 
FROM employee 
WHERE dob BETWEEN 380307 AND 420825 
ORDER BY dob ;

or

SELECT name, CAST (dob AS INTEGER) 
FROM employee 
WHERE dob BETWEEN 380307 AND 420825 
ORDER BY dob ;

and the display becomes:

Name             DOB
----------    ------
Inglis C      380307
Peterson J    420327