All Forums Teradata Applications
sayaksitex 24 posts Joined 09/12
24 Sep 2012
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)....

ulrich 816 posts Joined 09/09
24 Sep 2012

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);
 

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

Adeel Chaudhry 773 posts Joined 04/08
26 Sep 2012

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

-- If you are stuck at something .... consider it an opportunity to think anew.

Satyaki.De 4 posts Joined 08/12
06 Oct 2012

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.

Regards.

SD

sayaksitex 24 posts Joined 09/12
16 Oct 2012

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

You must sign in to leave a comment.