Query to convert Decimal(15) to date format 'yyyy-mm-dd'

Teradata Applications
Enthusiast

Query to convert Decimal(15) to date format 'yyyy-mm-dd'

Can anyone help me with the query to convert a decimal eg (19890523) to date format (1989-05-23)....

4 REPLIES
Senior Supporter

Re: Query to convert Decimal(15) to date format 'yyyy-mm-dd'

Asuming your decimal column has alwys dates in the format yyyymmdd

the following should work

select cast(19890523 as decimal(15,0)) as dt_in,

          cast((dt_in - 19000000) as date);

Teradata Employee

Re: Query to convert Decimal(15) to date format 'yyyy-mm-dd'

Is it the epoch date you have in DECIMAL(15,0)? .... any samples would help.

Re: Query to convert Decimal(15) to date format 'yyyy-mm-dd'

I don't think this is a complete information you have provided for any of the volunteers. No sample data, no version info.

It is always easy to put your Teradata version info along with some input data & your required output in a clear manner. Otherwise it is impossinble for us to predict whatever you are looking for.

You can use CAST function to do that. Now, if you provide the sample input then we may look into the actual case.

SD.

Enthusiast

Re: Query to convert Decimal(15) to date format 'yyyy-mm-dd'

Thanks Ulrich......its working!

@Satyaki-- sorry for incomplete info. its teradata 13...!