Date format transfer

Analytics

Date format transfer

Hi, just wondering if there is an easy way to transfer date in number key in to date format. For example, "20130701" into "2013-07-01". The cast function will translate the number into a very wired date. 

Thanks.

Jason

3 REPLIES
Teradata Employee

Re: Date format transfer

Hi Jason,

actually the cast function is a good way to do it.   If it does not fit your needs, then please clarify what you mean by "wired date".

Thank you,

Regards,

Vlad.

Re: Date format transfer

So for example, the cast function will transfer date key 20,130,720 into 7/20/3913. I think it might be a problem caused by value settings. PLS advice any appropirate translating function. Thank you very much.

Jason


N/A

Re: Date format transfer

Hi Jason,

based on the internal storage of a date in Teradata you should use this:

cast(20130701 - 19000000 as date)


Of course you should store a date in a DATE not in an INTEGER to avoid such trouble.

Dieter