Subtract 1 sec from a timestamp (2005-06-22 13:51:06)
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
Subtract 1 sec from a timestamp (2005-06-22 13:51:06)
Hi,
I need to load 2 columns, one with the Sysdate timestamp( I am using DSJobStartTimeStamp) , and the second with the timestamp -1sec.
Do I need to convert the value into internal form, subtract 1 sec from the value and again convert to oracle format or is there a better way to do it.
Thanks,
I need to load 2 columns, one with the Sysdate timestamp( I am using DSJobStartTimeStamp) , and the second with the timestamp -1sec.
Do I need to convert the value into internal form, subtract 1 sec from the value and again convert to oracle format or is there a better way to do it.
Thanks,
Subtracting 1 second
In Oracle SQL you could simply create a "derived" column in your Source OCI stage:
This is how to subtract 1 second:
(SYSDATE - (1/(1*24*60*60)))
This is how to subtract 1 second:
(SYSDATE - (1/(1*24*60*60)))
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
Hi got the logic:
OCONV((ICONV(DSJobStartTimestamp[1,10],"D-YMD[4,2,2]")) , "D4-YMD[4,2,2]") :
" " :
OCONV((ICONV(DSJobStartTimestamp[12,8],"MTS")-1), "MTS")
The first peice takes the incomming date and converts it into internal format and then back to o/p format
The second peice converts the time into internal, subtracts 1 sec and converts back into o/p format.
Thanks,
OCONV((ICONV(DSJobStartTimestamp[1,10],"D-YMD[4,2,2]")) , "D4-YMD[4,2,2]") :
" " :
OCONV((ICONV(DSJobStartTimestamp[12,8],"MTS")-1), "MTS")
The first peice takes the incomming date and converts it into internal format and then back to o/p format
The second peice converts the time into internal, subtracts 1 sec and converts back into o/p format.
Thanks,
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You have a problem if the incoming timestamp is 2005-06-22 00:00:00 for which the result should be 2005-06-21 23:59:59.
Create a stage variable or routine to handle this boundary condition.
Create a stage variable or routine to handle this boundary condition.
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.
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If you're going back from 00:00:00, then you need to subtract one day from the date.
Code: Select all
Oconv(Iconv(Left(InLink.Timestamp,10),"DYMD")-1,"D-YMD[4,2,2]")
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.