Calculation in 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
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Calculation in Stage Variable

Post by sam334 »

All,
I need to do a calculation in transformer. Kind of confused.

We have data in below format:

ID,DATE,STATUS
A,20150228,Active
B,20150228,Active

Now, if the process runs on March 31st, and if current date is more than DATE+31days then change status to Expired. So, if process runs on 2015-03-15 and as DATE is not 20150228+31 days, then it should be active.

Thanks for your help.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Convert your date string into an internal format date using StringToDate() function, then to the number of days from a given day zero - from which you can perform "day arithmetic".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sounds like a job for the DaysSinceFromDate function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Thanks Ray and Craig. But the source table data type is date, then we don't need to use STRINGTODATE right?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Correct... check the function I posted, it returns the number of days between two dates.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Perfectly worked. Many thanks....
Post Reply