Date plus months

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
John Smith
Charter Member
Charter Member
Posts: 193
Joined: Tue Sep 05, 2006 8:01 pm
Location: Australia

Date plus months

Post by John Smith »

Hi,

Is there a way to add months to a date in a PX job ? I can do that quite easily in the database e.g in Db2 date('2004-01-05') + 1 month

but I rather not code it in the database if I can do that in the job.

Thanks,

JS
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Nothing out of the box to add months. You can add days but not month. You can, however, create your own C routine to do that. It should'nt be hard.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

you can convert the date to string. Separate the date month and year using Field or any similar function. Now increment the month and concatenate all three. And convert it back to date. Now if the month is 12 then you need to increment the year and the month to 1. Check for that condition before concatenating and converting it to date. Hope that helps.
JeroenDmt
Premium Member
Premium Member
Posts: 107
Joined: Wed Oct 26, 2005 7:36 am

Post by JeroenDmt »

Maveric wrote:you can convert the date to string. Separate the date month and year using Field or any similar function. Now increment the month and concatenate all three. And convert it back to date. Now if the month is 12 then you need to increment the year and the month to 1. Check for that condition before concatenating and converting it to date. Hope that helps.
And if the day is 31?
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Exactly my point. All these validty checks and incrementions need to be handled in a structered piece of code. Go for a routine.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I/OConv would handle all of those concerns automagically. Are they not available in PX jobs?
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Only with a basic transformer, not with px transformer.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply