Hi,
We are trying to derive difference between two timestamps(in hours)
Any ideas are welcome
Derriving difference of two timestamps
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 7
- Joined: Thu Sep 30, 2004 5:22 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard! :D
There is no built-in operator for this task; you probably have to construct your own. Do you need whole hours or fractional? If whole hours, is this a rounded or truncated number? (A truncated number would be "completed hours".)
Basically you have to pick apart each timestamp, convert all the pieces to a common format (seconds is recommended), perform the arithmetic, and assemble the result.
Because you're in a parallel job, you would do this in a BuildOp (refer to Chapter 55 of the Parallel Job Developer's Guide for more information).
There is no built-in operator for this task; you probably have to construct your own. Do you need whole hours or fractional? If whole hours, is this a rounded or truncated number? (A truncated number would be "completed hours".)
Basically you have to pick apart each timestamp, convert all the pieces to a common format (seconds is recommended), perform the arithmetic, and assemble the result.
Because you're in a parallel job, you would do this in a BuildOp (refer to Chapter 55 of the Parallel Job Developer's Guide for more information).
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.
In a transformer:
This should get you started using truncated hours. It does not deal with differences with regards to minutes, or anything like that.
The field using this code needs to be an integer.
That was fun making this.
Code: Select all
((JulianDayFromDate(TimestampToDate(Input.currentTime)) * 24) + (HoursFromTime(TimestampToTime(Input.currentTime)))) - ((JulianDayFromDate(TimestampToDate(Input.oldTime)) * 24) + (HoursFromTime(TimestampToTime(Input.oldTime))))
The field using this code needs to be an integer.
That was fun making this.
-
- Participant
- Posts: 7
- Joined: Thu Sep 30, 2004 5:22 am
Thanks,
But in the meanwhile we got some other solution to achieve the same.
We defined a stage variable and defined it as decimal , the derivation of which is as follows..
DFloatToDecimal(SecondsSinceFromTimestamp(INPUT_TIMESTAMP,CURRENT_TIMESTAMP))
It is working fine.......
"FEEDBACK IS THE BREAKFAST OF CHAMPIONS"
But in the meanwhile we got some other solution to achieve the same.
We defined a stage variable and defined it as decimal , the derivation of which is as follows..
DFloatToDecimal(SecondsSinceFromTimestamp(INPUT_TIMESTAMP,CURRENT_TIMESTAMP))
It is working fine.......
"FEEDBACK IS THE BREAKFAST OF CHAMPIONS"