How to Add Months In DataStage

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
Vinodanand
Premium Member
Premium Member
Posts: 112
Joined: Mon Jul 11, 2005 7:54 am

How to Add Months In DataStage

Post by Vinodanand »

Hi,

Is there a function in datastage server which can add months,something similar to ADD_Months function in Oracle.

I need to increment months based on an index ...

Can anyone help me out on this...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is no out of the box function. It is easy enough to write one.
  • Add Int(Months/12) to the years.

    Add Mod(Months,12) to the months.

    Adjust if the new months figure is greater than 12.

    Adjust by subtracting days if the number of days in the new month is illegal.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Vinodanand
Premium Member
Premium Member
Posts: 112
Joined: Mon Jul 11, 2005 7:54 am

Post by Vinodanand »

ray.wurlod wrote: There is no out of the box function. It is easy enough to write one.
  • Add Int(Months/12) to the years.

    Add Mod(Months,12) ...
Hi,

Thnx ray... But What i want to know is , assume i have a running counter and i need to increase my month by adding the counter to it.

i.e. month= 03 and counter = 01 for 1st run

Therefore : when x = month + counter = 03 +1 = 04.


run 2 : month = 03 counter = 02

when x = month + counter = 03 +2 = 05.

Is there any function which could add months based on a counter...
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Or you can workaround with Iconv/Oconv.
'Oconv(Iconv(date,"D"),DM) + counter' to add up the month.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
pneumalin
Premium Member
Premium Member
Posts: 125
Joined: Sat May 07, 2005 6:32 am

Post by pneumalin »

Why don't you create c routine to do it. The time sructure will allow you to do everything about manipulating the date.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you've already got months and counter, then

Code: Select all

If (months + counter > 12) Then months + counter - 12 Else months + counter 
assuming months + counter can never be less than 1 or more than 24. All data types are uint8 or a larger or signed integer.
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