If the input column is in the last four months then X then Y

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
jpradeep.net
Participant
Posts: 21
Joined: Mon Jul 12, 2010 2:05 am
Location: India

If the input column is in the last four months then X then Y

Post by jpradeep.net »

I have an input column and its datatype is integer. the source data is in the format of '20100823'.It means 2010(Year),08(month),23(Date).

My question is if the input column is in the last four months then it is X and if not then it is Y. Here we need to consider the year also.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

svYYYY_MM=DsJobStartTimestamp[1,7]
svYear=svYYYY_MM[1,4]
svMon=svYYYY_MM[6,2]
inp='20100823'
svInpYear=inp[1,4]
svInpMon=inp[5,2]

If (svYear - svInpYear)*12 + svMon - svInpMon <= 4 Then 'X' Else 'Y'
You are the creator of your destiny - Swami Vivekananda
jpradeep.net
Participant
Posts: 21
Joined: Mon Jul 12, 2010 2:05 am
Location: India

Post by jpradeep.net »

Thanks a lot Anbu
jpradeep.net
Participant
Posts: 21
Joined: Mon Jul 12, 2010 2:05 am
Location: India

Post by jpradeep.net »

"DsJobStartTimestamp[1,7]" means current timestamp?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It means the first 7 characters from the output of the DSJobStartTimestamp macro, which is a constant that is the date/time that the job started.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply