Subtract 1 second

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Jim Grover
Charter Member
Charter Member
Posts: 6
Joined: Tue May 09, 2006 1:57 pm

Subtract 1 second

Post by Jim Grover »

I need to subtract one second from the current time in a parallel job; does anyone have an approach or an example?

much appreciated
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Hello Jim,

PX has a number of builtin functions for handling time and timestamps. If you have a timestamp value, you can use the function TimestampFromSecondsSince to subtract one second from a timestamp value.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Basically, you need to convert into the internal format of datastag (using TimestampFromSecondsSince or TimestampFromDateTime or TimeFromMidnightSeconds or SecondsSinceFromTimestamp.... ) and subtract 1 second from it and convert it back to the required format.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Jim Grover
Charter Member
Charter Member
Posts: 6
Joined: Tue May 09, 2006 1:57 pm

Post by Jim Grover »

Thank you both for the help; I had played with TimestampFromSecondsSince but was not using it in the correct way. I've now got it working.
mjmagalsky
Participant
Posts: 5
Joined: Wed Apr 18, 2007 2:38 pm

Subtracting a millisecond from a Timestamp

Post by mjmagalsky »

I have a similar need but I need to subtract one millisecond from a timestamp. However, TimestampFromSecondsSince is apparently only partially-compatible with subsecond times. For example, this derivation:
TimestampFromSecondsSince(-.001, FunneledData.TRANSACTION_TIME)
yields this result:
Input :2007-04-11 15:42:28.113000
Output:2007-04-11 15:42:27.999000

It appears to round down to the full second and then subtract the partial second. Any input or alternative suggestions are appreciated.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

Etiquette Note
We don't hijack threads. This is not the identical problem, and will have a different solution, so you must start a new thread.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply