Page 1 of 1

Add Months to a Date

Posted: Thu Mar 29, 2007 12:01 am
by dw_prasanta
Could you please give some guide lines how to Add months to a date in DataStage PX?

Thanks in Advance.

Regards,
Prasanta

Posted: Thu Mar 29, 2007 5:06 am
by ray.wurlod
There's nothing out of the box. Design your algorithm (incorporating your business rules, such as what happens if the date is January 31 and you add one month) and create a routine. Or get a database query to perform it.

Posted: Thu Mar 29, 2007 7:44 am
by swades
which database are you using?
I think in Oracle there is ADD_MONTHS function.

Posted: Thu Mar 29, 2007 7:47 am
by DSguru2B
There is a similar Basic function by Ray on his home page, which works great. You can convert the logic to C code, with his permission offcourse.

Posted: Thu Mar 29, 2007 3:46 pm
by ray.wurlod
The Oconv() and Iconv() functions used in that routine might make life tricky, however.

You could, I guess, use the ICI functions ic_iconv() and ic_oconv(). You will find these documented in the Intercall Reference Guide on the IBM UniVerse web site.

Posted: Thu Nov 29, 2007 9:14 pm
by devidotcom
Thanks Ray for this routine on your home page.
I went through the routine for AddMonth()
I want to use this routine in the transformer stage and add 6 months to the current date.

I created a server routine and compiled it. It works fine. I am using PX 7.5.2
I have never called a transform routine in the transformer routine in the transformer stage. Could anyone explain in detail how to call this routine. Or is it that we can't execute a server routine in a transformer stage.

One more doubt in the routine written by Ray we use Iconv() and Oconv() functions these are function that can be used in server jobs only... is that right? Then how would I use this routine in a PX job.

Posted: Thu Nov 29, 2007 9:35 pm
by ray.wurlod
BASIC routine ---> server job only, or BASIC Transformer stage in parallel job

Parallel routine ---> parallel job

You could, as suggested, re-write the logic as a parallel routine (in C++) and invoke that from a parallel Transformer stage.

Posted: Thu Nov 29, 2007 10:05 pm
by devidotcom
Is there a parallel routine in your home page for AddMonth()

Posted: Fri Nov 30, 2007 12:03 am
by ray.wurlod
No.

That's why I suggested that you could re-write it.

Posted: Fri Nov 30, 2007 12:10 am
by devidotcom
Thanks Ray