Converting a date to the Terdata date format

Database

Converting a date to the Terdata date format

What is the best way to convert 'yyyy-mm-dd' to the Teradata interger storage of a date? (yyyy-1900)mmdd

For example:

If my date was April 1, 2012 and it was stored in the database column in the format 'yyyy-mm-dd'.

This is what I am trying to get: 1120401

2 REPLIES

Re: Converting a date to the Terdata date format

Is this the best way or is there a different way that is more efficient?

select cast(current_date as INTEGER) myTest

N/A

Re: Converting a date to the Terdata date format

This is the best way, because there's no conversion neccessary as it Teradata's internal format.

But way do you need it?

"stored in the database column in the format 'yyyy-mm-dd'" is not correct, a DATE is always stored using an integer as you described, the format used for a cast to a string is controlled by the FORMAT string.

Dieter