Stage variable

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Stage variable

Post 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
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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]
Last edited by kcbland on Wed Apr 30, 2008 11:28 am, edited 1 time in total.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post 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
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post 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
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

I corrected my post above to reference the leading year digit at 5. Please reconsider that answer.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
sheema
Premium Member
Premium Member
Posts: 204
Joined: Sat Jul 22, 2006 10:20 am

Post 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
Post Reply