AddMonths routine

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Ragunathan Gunasekaran
Participant
Posts: 247
Joined: Mon Jan 22, 2007 11:33 pm

AddMonths routine

Post by Ragunathan Gunasekaran »

Ho to use the AddMonths routine in the transformer stage.
The syntax is given but the arguments to be filled up in the routine is not defined clearly

syntax is :AddMonths(%AddToDate%, %AddMonths%, %InMask%, %OutMask%, %LogWarnings%)

what the arguments in the routine represent and how ti utilise this routine in the transormer stage?
Regards
Ragu
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

You are talking about a custom routine. Open the routine in your project if it is available under routines section and try to understand what needs to be passed as parameters or Just search for "AddMonths" you will get similar posts. :o Sure you can figure out from them what needs to be passed to the routine you are talking about.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

There is also AddMonth() routine by Ray. Search will turn it up.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: AddMonths routine

Post by sachin1 »

May be below code meet your requirement,

name of routine DETERMINEDAY, with input parameter Arg1 in format 2007-05 or 2007-12.
----------------------------------------------------------------
output format : TEST #1
*******
Arg1 = 2007-05
Test completed.
Result = 01/06/2007
----------------------------------------------------------------
it uses some internal routines, which are available for datastage 7.2 server edition.


---------------------start of routine-------------------------------------
Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"
Equate TransformName To "ConvertMonth"
Ans = ""
* Check the format of the input value.
If Not(Arg1 Matches "4N'-'1-2N") Then
ErrorMsg = DSRMessage("DSTAGE_TRX_E_0001", "Invalid MONTH.TAG '%1'", Arg1)
Call DSTransformError(ErrorMsg, TransformName)
Reply = "not valid"
Ans = Reply
GoTo ExitDETERMINEDAY
End

InYear = Arg1[1,4]
InMonth = Arg1[6,2]
If InMonth < 1 Or InMonth > 12 Then
ErrorMsg = DSRMessage("DSTAGE_TRX_E_0002", "Invalid month number '%1' in tag '%2'",
InMonth:@FM:Arg1)
Call DSTransformError(ErrorMsg, TransformName)
Reply = "not valid"
Ans = Reply
GoTo ExitDETERMINEDAY
End

* Internal date for last day of month -
* compute this from the first day of the next month.
InMonth = InMonth + 1
If InMonth > 12 Then
InYear = InYear + 1
InMonth = 1
End
Reply = Iconv("1/":InMonth:"/":InYear, "D/DMY")
Ans = Oconv(Reply, "D/E")
ExitDETERMINEDAY:
------------------------end of routine------------------------------------------
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try downloading 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.
Post Reply