Hi ,
I am new to datastage. Is there a function or a transform that helps in addition of timestamps. I have a timestamp "2004-06-13 22:30:08". For this I need to add 7 hours and get the timestamp "2004-06-14 05:30:08". Can you please suggest me a way to do this.
Thanks in advance,
Bhalachandra
Timestamp addition
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard! :D
You have two choices; you can convert to internal date and time formats and perform the arithmetic then convert back to timestamp format, or you can deal with the substrings in the timestamp and perform the arithmetic on these. The latter works because there are effectively no data types while data are in DataStage.
You have two choices; you can convert to internal date and time formats and perform the arithmetic then convert back to timestamp format, or you can deal with the substrings in the timestamp and perform the arithmetic on these. The latter works because there are effectively no data types while data are in DataStage.
Code: Select all
Delta = 7
DatePart = Iconv(TheData[1,10], "DYMD")
TimePart = Iconv(TheData[12,8], "MT") ; * seconds since midnight
TimePart += (Delta * 3600)
If TimePart > 86400
Then
TimePart -= 86400
DatePart += 1
End
Ans = Oconv(DatePart, "D-YMD[4,2,2]") : " " : Oconv(TimePart, "MTS:")
Code: Select all
Delta = 7
Hours = TheData[12,2]
If Hours < (24 - Delta)
Then
TheData[12,2] = Fmt(Hours + Delta, "R%2")
End
Else
TheData[12,2] = Fmt(Hours + Delta - 24, "R%2")
TheData[9,2] = Fmt(TheData[9,2] + 1, "R%2")
End
Ans = TheData
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.