HI
i am new to datastage.I want to know how to write routine for following
situation
expiry date( in timestamp) = effective date - 1.i tried using iconv and oconv but i am not able to get result.
thanks
sai
ROUTINES
Moderators: chulett, rschirm, roy
Sainath,
ICONV and OCONV will do what you tell them to. If I understand your question correctly, you want to write a function that returns a timestamp (I'll assume that you want YYYY-MM-DD HH:MM:SS) using either the current date.
Function MySampleRoutine(Unused)
Ans = OCONV(@DATE-1,'D-YMD[4,2,2]'):' ':OCONV(@TIME,'MTS')
Return(Ans)
(The green colored text comes from the DS function design)
This is a 1-liner which can be done directly in a transform variable or a derivation.
Is this what you were asking?
ICONV and OCONV will do what you tell them to. If I understand your question correctly, you want to write a function that returns a timestamp (I'll assume that you want YYYY-MM-DD HH:MM:SS) using either the current date.
Function MySampleRoutine(Unused)
Ans = OCONV(@DATE-1,'D-YMD[4,2,2]'):' ':OCONV(@TIME,'MTS')
Return(Ans)
(The green colored text comes from the DS function design)
This is a 1-liner which can be done directly in a transform variable or a derivation.
Is this what you were asking?
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Almost but not quite. I suspect EffectiveDate is an input value, so needs to be the Routine argument. If it's an external-format date it will need an ICONV applied to it before the arithmetic. If it's a timestamp it will need decomposition into date and time components.
Code: Select all
FUNCTION ExpiryDate(EffectiveDate)
* Effective date is a Timestamp: decompose into date and time
EffDate = Field(EffectiveDate, " ", 1, 1)
EffTime = Field(EffectiveDate, " ", 2, 1)
* Convert date component into internal format
IntDate = Iconv(EffDate, "DYMD")
* Calculate date component of expiry date (business logic)
NewDate = IntDate - 1
* Convert that date into external format
ExpDate = Oconv(NewDate, "D-YMD[4,2,2]")
* Construct timestamp to return to caller
Ans = ExpDate : " " : EffTime
RETURN(Ans)
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.