All Forums Analytics
tera_cert 2 posts Joined 07/07
29 Oct 2007
Integer to date conversion - Error

Here is the query i am trying to run :select cast(cast(cast(cal.cal_id as integer format '9999999999') as varchar(10) ) as timestamp(0) format 'YYYYMMDDHH') from miesa01.calen cal Here cal_id is an integer column.. i have tried all the variations for this .. the strange part is the following query works perfectly fineselect cast(cast(cast(2007090909 as integer format '9999999999') as varchar(10) ) as timestamp(0) format 'YYYYMMDDHH') from miesa01.D_CAL_CALENDAR cal Please try to pur your ideas and experience. Thanks,Laxmi

dnoeth 4628 posts Joined 11/04
30 Oct 2007

Hi Laxmi,providing the actual error is more helpful than just "doesn't work".And why do you cast cal_id to an integer if it's already an integer?Dieter

Dieter

famalau 43 posts Joined 08/07
09 Nov 2007

Laxmi,Maybe the following structure helps you:create table test (id INTEGER);INSERT TEST VALUES (2007090909);INSERT TEST VALUES (2007110914);SELECT CAST((CAST (ID AS CHAR(10))) AS TIMESTAMP FORMAT 'YYYYMMDDHH')FROM TEST;Good luck!

Regards,

Fabio

You must sign in to leave a comment.