Page 1 of 1

Date plus months

Posted: Thu May 31, 2007 5:55 am
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

Posted: Thu May 31, 2007 7:32 am
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.

Posted: Fri Jun 01, 2007 6:47 am
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.

Posted: Fri Jun 01, 2007 7:03 am
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?

Posted: Fri Jun 01, 2007 7:37 am
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.

Posted: Fri Jun 01, 2007 7:54 am
by chulett
I/OConv would handle all of those concerns automagically. Are they not available in PX jobs?

Posted: Fri Jun 01, 2007 8:12 am
by DSguru2B
Only with a basic transformer, not with px transformer.