Adding 1 to the months

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
dsquestion
Participant
Posts: 26
Joined: Thu Feb 03, 2005 1:05 am

Adding 1 to the months

Post by dsquestion »

Hi All,
I want to add 1 to the months till my counter reaches 24.

For Example.

SOURCE

LOCATIONID, ITEMID, DATE, QTY1, QTY2.......QTY24
------------------------------------------
1, 2, jan-05, 12, 16.........39


TARGET

LOCATIONID, ITEMID, DATE, ADDED_DATE, QTY
-------------------------------------------
1, 2, jan-05, jan-05, 12
1, 2, jan-05, feb-05, 16
-
-
-
1, 2, jan-05, dec-06, 39

If you see the above example one is added to the date column from the
Source ie.jan-05 and it is been incremented till it reaches dec-06 i.e.24 times based on the qty1--qty24 from the source


Thanks in advance.comments appreciated
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Hello this seams like a pivoting question, there are dynamic approaches, which have to be though about deeper, as quick and dirty I will sugest a static approach to you, which is (most of you will blame me) a lot to write but simple.

You set up 24 outlinks and in each field you set up the relevant fields and put them into target.

For to calculate the new Date use the following function:

function addDate(InDate,Number)
NumDate=oconv(iconv(Date,"D-MY"),"D-MY[2,4]")
Month=field(NumDate,"-",1)
Year=field(NumDate,"-",2)
NewMonth=Month+Number
ResMonth=Mod(NewMonth,12)
AddYear=INT(NewMonth/12)
ResYear=Year+AddYear
NewDate=oconv(iconv(ResMonth:"-":ResYear,"D-MY[2,4]"),"D-MY[A3,4]")
Ans=NewDate
Return(Ans)

Hope it is a quick help.

Wolfgang
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
First there is no need to post in both EE and Server forum.
second take a look at this.
I found this after a few minits of using the search mechanism :!:
IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Post Reply