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?
AddMonths routine
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 247
- Joined: Mon Jan 22, 2007 11:33 pm
AddMonths routine
Regards
Ragu
Ragu
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
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. 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>
<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>
Re: AddMonths routine
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------------------------------------------
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------------------------------------------
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.