Hello,
I am looking to get the current timestamp minus 5 hours. For example if right now is:
2016-04-26 18:01:15
It will return 2016-04-26 13:01:15
Another example if now is:
2016-04-26 01:01:15
It will return: 2016-04-25 20:01:15
Looking to do this in a user variable stage.
Subtract Hours from Current Timestamp
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 48
- Joined: Wed Jan 07, 2015 3:30 pm
-
- Premium Member
- Posts: 48
- Joined: Wed Jan 07, 2015 3:30 pm
You were too quick. I removed my post when I noticed you said "in a User Variable stage" (which means a Sequence job) and I thought you were looking for a Parallel function. While I was removing it you replied.
No it does not and we're in the wrong forum to boot. Hang on a sec.
No it does not and we're in the wrong forum to boot. Hang on a sec.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Perhaps Ray is still giving away his BASIC routines to do date and time math, that would certainly make things easier. Otherwise I think you're going to need do some of your own. Something like:
1. IConv to convert the time to internal format
2. Subtract 18000 (5 hours in seconds)
3. Handle any 'underflow' including subtracting 1 day from the date
4. OConv to put it all back into a string
1. IConv to convert the time to internal format
2. Subtract 18000 (5 hours in seconds)
3. Handle any 'underflow' including subtracting 1 day from the date
4. OConv to put it all back into a string
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Click any of the links on my new home page which takes you to a public page on OneDrive. Download RayWurlodDateRoutines.dsx from there.
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: 48
- Joined: Wed Jan 07, 2015 3:30 pm
-
- Premium Member
- Posts: 48
- Joined: Wed Jan 07, 2015 3:30 pm
Time in internal format is the number of seconds past midnight. When you subtract 18000 seconds from it, it may go negative which is what I meant by 'underflow'. When that happens, you need to decrement the day by 1 and then adjust the time accordingly... add back 86400 seconds... something I'm sure Ray is already doing and you can crib from if need be.
In other words, the scenario you covered in your second example.
In other words, the scenario you covered in your second example.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers