I need No of Months after subtracting one date from 2nd dat

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
justicevb
Participant
Posts: 10
Joined: Thu Jul 03, 2008 6:07 am

I need No of Months after subtracting one date from 2nd dat

Post by justicevb »

I need to find Number of months after subtracting one date from other date,
Please find the requirement below

NUMBER OF MONTHS (MOAT_DT - TODAY())

I need the result of Number of Months after subtracting TODAY() date from MOAT_DT

Plesae suggest me regarding this.

Thanks in advance
vb
xxx
Pierre
Participant
Posts: 66
Joined: Thu May 24, 2007 7:16 am
Location: Paris

Post by Pierre »

Can you describe the result you expect ?

I mean, if today is 2009-01-07 and previous date is 2008-12-06, do you expect 1 or 2 months ?
And if today is 2009-01-07 and previous date is 2008-12-08, do you expect 0 or 1 month ?

And so on... :?:

Pierre.
Felix qui potuit rerum cognoscere causas. Virgile (Géorgiques).
yousuff1710
Participant
Posts: 56
Joined: Fri Sep 21, 2007 9:10 am
Location: Bangalore

Post by yousuff1710 »

Use function DaysSinceFromDate & then divide by 30.
Take o/p column in integer type.
You will get the required o/p, I guess.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Never re-invent the wheel where you don't need to. For example a set of date arithmetic functions can be had from here
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

yousuff1710 wrote:Use function DaysSinceFromDate & then divide by 30.
Not in a Server job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted, the answer will depend on your definition of 'month' when computing the number of months between dates. If your definition aligns with Ray's then you're all set. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply