Add Months to a Date

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
dw_prasanta
Participant
Posts: 12
Joined: Mon Nov 27, 2006 1:28 am

Add Months to a Date

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
swades
Premium Member
Premium Member
Posts: 323
Joined: Mon Dec 04, 2006 11:52 pm

Post by swades »

which database are you using?
I think in Oracle there is ADD_MONTHS function.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

Is there a parallel routine in your home page for AddMonth()
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No.

That's why I suggested that you could re-write it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

Thanks Ray
Post Reply