Page 1 of 1

Stage variable

Posted: Wed Apr 30, 2008 11:02 am
by sheema
I have a input column number,which is date coming in as mmddyy(12908)
i have to convert it into yyyymmdd into output number column.
If yy >10 then i append 19 to the year else 20 to the year.

So I am doing the below in 2 stage variables(of data type varchar)

sv1 If len(col1)=5 then 0:col1 else col1

sv2 If Right(sv1,2) >10 then '19':sv1[5,2]:sv1[1,2]:sv1[3,2]
ELSE '20':sv1[5,2]:sv1[1,2]:sv1[3,2]

But even though Right(sv1,2) is less than 10 ,19 is getting appended.
For the above date i am getting as out put is 19080129 where as it should be 20080129.
I got the point that Right(sv1,2) >10 is always evaluated as true.

Can some one kindly help me how to solve this.

Thanks

Posted: Wed Apr 30, 2008 11:11 am
by kcbland
If you're assuming xx10 is 2010, then just check for 0 at sv1[5,1].

sv2 (If sv1[5,1]=0 then '20' else '19'):sv1[5,2]:sv1[1,2]:sv1[3,2]

Posted: Wed Apr 30, 2008 11:20 am
by ds_developer
Just by looking, I would say the
Right(sv1,2) >10
is comparing the text string '08'>10 which must evaluate to True. You might want to change it to Right(sv1,2) > '10' and see if that works. But then again, I wouldn't do this test because in 3 years when it is 2011 your result would be incorrect...

Just my opinion,
John

Posted: Wed Apr 30, 2008 11:24 am
by sheema
I tried using Right(sv1,2) > '10' but that is also not getting me wrong year i.e it is 19 instead of 20.The business rule i was given was to check for >10 than put 19 in front of 2 digit year or else 20 .

Thanks

Posted: Wed Apr 30, 2008 11:29 am
by kcbland
I corrected my post above to reference the leading year digit at 5. Please reconsider that answer.

Posted: Wed Apr 30, 2008 12:14 pm
by sheema
Kenneth,

your suggestion would work if sv1[5,1]=0 if year is less than 10,i.e 2009 but if I want to check if year is 2010 too.How can i get that done.

Thanks