Add month to a given date

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
xli
Charter Member
Charter Member
Posts: 74
Joined: Fri May 09, 2003 12:31 am

Add month to a given date

Post by xli »

hi

I am wondering if DataStage has a simple function to do the same thing as oracle function ADD_MONTHS()

Thanks

xli :roll:
denzilsyb
Participant
Posts: 186
Joined: Mon Sep 22, 2003 7:38 am
Location: South Africa
Contact:

Post by denzilsyb »

hi xli

Im no oracle expert, but tell us what add_months() does andn we can answer the question. Also, tell us what where you want to use this function so that we can suggest the best answer.
dnzl
"what the thinker thinks, the prover proves" - Robert Anton Wilson
jclin777
Participant
Posts: 5
Joined: Tue Nov 11, 2003 2:20 pm

Post by jclin777 »

I don't believe so, but someone posted a function on this forum before which will do the trick as ADD_MONTHS, see below

FUNCTION AddMonthsToDate(BaseDate, Months)
Equate RoutineName To "AddMonthsToDate"
Ans = @NULL
Test = Iconv(BaseDate, "DYMD")
If Status() = 0 And BaseDate Matches "8N" Then
If Months Matches "1N0N" : @VM : "'+'1N0N"
Then
Year = BaseDate[1,4]
Month = BaseDate[5,2]
Day = BaseDate[7,2]
Month += 6
If Month > 12
Then
Month -= 12
Year += 1
End
Ans = Fmt(Year,"R%4") : Fmt(Month("R%2") : Day
End
Else
Call DSTransformError("Non-integer months in Arg2.", RoutineName)
End
End
Else
Call DSTransformError("Invalid date " : Quote(BaseDate), RoutineName)
End
RETURN(Ans)


James
xli
Charter Member
Charter Member
Posts: 74
Joined: Fri May 09, 2003 12:31 am

Post by xli »

denzilsyb, what I mean is add/minus n months to a given date, it's exactly what the oracle add_months() function does.

jclin777, thanks for your post, I know I can created a routine to handle it. I was just wondering if there is a simple built-in funciton I haven't discover to do it. However, it seems the answer is nagative.

cheers, xli
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is definitly no intrinsic function for any form of interval handling.

Of course, once you've built the Routine, it's built-in for ever more! (Looks kinda like one of mine.)
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