TimeStamp Difference

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
Raftsman
Premium Member
Premium Member
Posts: 335
Joined: Thu May 26, 2005 8:56 am
Location: Ottawa, Canada

TimeStamp Difference

Post by Raftsman »

Hi all,

I searched the forum for an answer and still I have not found one. My problem is,

I want to find the difference (right down to the microsecond) between two timestamps. I can see the timestamp and microseconds from the input but I can't seem to find a function that will allow me to do this. I thought of creating a server routine, but I don't think I will be able to see it in the Parallel Transformer.

Is there a solution on the forum that I didn't find or has someone come up with a BuildOp that will solve this problem.

Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Does your version of Windows even deliver microseconds when a call is made to the system clock?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Raftsman
Premium Member
Premium Member
Posts: 335
Joined: Thu May 26, 2005 8:56 am
Location: Ottawa, Canada

Post by Raftsman »

The input comes from DB2 mainframe. I modified the field attributes with extended equal to microseconds. I can get the microseconds from DB2. What I was hoping to accomplish was write a routine or BuildOp that would take the start and end timestamps and provide the difference in seconds. I started to code a server routine only to find out that it wasn't visible in the PX transformer. I don't want to use the Basic Transformer. Another problem I encountered was trying to use DS functions within the coding. I am not sure if this is possible as well.

Thanks
Raftsman
Premium Member
Premium Member
Posts: 335
Joined: Thu May 26, 2005 8:56 am
Location: Ottawa, Canada

Post by Raftsman »

Also, no I can't get the microseconds from the system clock. I spoke with IBM and they said there may be a fix somewhere down the road. Hopefully, a simpler solution is created.
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

Getting jitter free microsecond resolution from Wintel platform will be difficult. There are hardware plugs-ins that can easily resolve to that granularity, but associating the timestamp to the event still requires the CPU and OS, which are too often busy doing other things.

Here's a link to folks facing similar challenges:

http://www.csm.ornl.gov/~dunigan/atmgps/

In the end, it would be cheaper/easier to just use a UNIX box.

Carter
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

Getting jitter free microsecond resolution from Wintel platform will be difficult. There are hardware plugs-ins that can easily resolve to that granularity, but associating the timestamp to the event still requires the CPU and OS, which are too often busy doing other things.

Here's a link to folks facing similar challenges:

http://www.csm.ornl.gov/~dunigan/atmgps/

In the end, it would be cheaper/easier to just use a UNIX box.

Carter
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Was the second post a "jitter on your Windows box"? :lol:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Well, you can always work at the millisecond level, which IS supported. Indeed you can get the values for CPU and elapsed time (to millisecond accuracy, rounded) in log messages, so you don't even need to calculate them yourself.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can write a c function. Use the time.h library. It has time structs that can get your work done. You can also do string manipulation within C. Read it like

Code: Select all

sscanf("%4d-%2d-%2 %2:%2:%2.%6d", &yr, &mo, &dy, &hh, &mm, &ss, &nn)
You can do the same for the second timestamp and minus them and return a concatenated value. This is a very general direction, for details you need to google it.
Last edited by DSguru2B on Wed Dec 20, 2006 10:47 am, edited 1 time in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Use split micro seconds and rest of the portions. And you can use SecondsSinceFromTimestamp and multiply with 1000000. Add the microsecond and the resultant. Now you can manipulate as you wish.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

All of which assumes that the OP can actually get microseconds from the system clock. On Windows platforms I suspect not, hence my first post on this 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.
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

ray.wurlod wrote:Was the second post a "jitter on your Windows box"? :lol:
Yes, in fact it was!
Post Reply