Calculation on 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
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Calculation on DATE

Post by benny.lbs »

Can anyone help on the following case. Thanks a lot!!!

I have a date field and want to calculate the date after 24 month, does any function exist in Transformer or any other else ?
rumu
Participant
Posts: 286
Joined: Mon Jun 06, 2005 4:07 am

Re: Calculation on DATE

Post by rumu »

benny.lbs wrote:Can anyone help on the following case. Thanks a lot!!!

I have a date field and want to calculate the date after 24 month, does any function exist in Transformer or any other else ?
Hi,
There is a custom routine called "AddMonthsToCurrentMonth(%Arg1%, %Arg2%)".Here u need to extract month part from ur date field and use it as Arg1 and in Arg2 use 24.
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Re: Calculation on DATE

Post by benny.lbs »

rumu, thanks for your reply, but where can I find/call this routine ?
rumu wrote:
benny.lbs wrote:Can anyone help on the following case. Thanks a lot!!!

I have a date field and want to calculate the date after 24 month, does any function exist in Transformer or any other else ?
Hi,
There is a custom routine called "AddMonthsToCurrentMonth(%Arg1%, %Arg2%)".Here u need to extract month part from ur date field and use it as Arg1 and in Arg2 use 24.
rumu
Participant
Posts: 286
Joined: Mon Jun 06, 2005 4:07 am

Re: Calculation on DATE

Post by rumu »

benny.lbs wrote:rumu, thanks for your reply, but where can I find/call this routine ?
rumu wrote:
benny.lbs wrote:Can anyone help on the following case. Thanks a lot!!!

I have a date field and want to calculate the date after 24 month, does any function exist in Transformer or any other else ?
Hi,
There is a custom routine called "AddMonthsToCurrentMonth(%Arg1%, %Arg2%)".Here u need to extract month part from ur date field and use it as Arg1 and in Arg2 use 24.
You will find it under Ruotine/custum folder.Try it using Manager.
benny.lbs
Participant
Posts: 125
Joined: Wed Feb 23, 2005 3:46 am

Re: Calculation on DATE

Post by benny.lbs »

The path does NOT exist :<
rumu wrote:You will find it under Ruotine/custum folder.Try it using Manager.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Benny,

I think that rumu meant Routines/Custom, further the routine AddMonthsToCurrentMonth seems like a custom routine which they developed themselves. Therfore you will not find it.

Your best bet would be to implement your own logic using the combination of Iconv and Oconv functions.
Thanks,
Naveen
als110
Participant
Posts: 43
Joined: Fri Nov 05, 2004 11:21 am
Location: United States

Post by als110 »

I have done this first by converting the date to a julian day and since you wanted to know 24 months ahead add 730 to the julian date and then convert if back to date. It is a crazy work around but it works for what you need
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What about leap years?

For 24 months wouldn't it be easier to add 2 to the year component, then roll back one day if the result is 29 Feb?

This algorithm fails for the year 2BC but otherwise is OK. You could build in a check for this if you are likely to process dates in that range.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply