All Forums Database
teradatatester 69 posts Joined 01/10
25 Apr 2012
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

teradatatester 69 posts Joined 01/10
25 Apr 2012

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

select cast(current_date as INTEGER) myTest

dnoeth 4628 posts Joined 11/04
25 Apr 2012

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

 

Dieter

You must sign in to leave a comment.