Page 1 of 1

AddMonths routine

Posted: Thu May 31, 2007 5:21 am
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?

Posted: Thu May 31, 2007 5:48 am
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.

Posted: Thu May 31, 2007 7:28 am
by DSguru2B
There is also AddMonth() routine by Ray. Search will turn it up.

Re: AddMonths routine

Posted: Mon Jun 04, 2007 10:02 am
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------------------------------------------

Posted: Mon Jun 04, 2007 9:23 pm
by ray.wurlod
Try downloading from here