Difference between 2 timestamps in minutes?

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
mczern
Premium Member
Premium Member
Posts: 80
Joined: Thu Jan 20, 2005 8:38 am
Location: Atlanta, GA
Contact:

Difference between 2 timestamps in minutes?

Post by mczern »

I am attempting to get the difference betwenn 2 timestamps as a result in minutes.

IE: Timestamp1 - Timestamp2 = X minutes (Numeric).

I can do it within the Oracle SQL query, but I'd like to do it within DataStage.
Mike Czerniawski
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Subtracting two timestamps would give you the difference in seconds, so you'd need to multiply the result by 60 and decide how to handle any fractions. What have you tried so far and what happened when you tried it?
-craig

"You can never have too many knives" -- Logan Nine Fingers
mczern
Premium Member
Premium Member
Posts: 80
Joined: Thu Jan 20, 2005 8:38 am
Location: Atlanta, GA
Contact:

Post by mczern »

chulett wrote:Subtracting two timestamps would give you the difference in seconds, so you'd need to multiply the result by 60 and decide how to handle any fractions. What have you tried so far and what happened when you tried it?
Maybe I'm just not declaring the result correctly... I declared it as Numeric 10.
I get a compiler error...
Error in output column derivation expression for column DIFF_DT in link src_hnamdwh2. Invalid conversion requested from a timestamp to a dfloat.
Mike Czerniawski
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... you've added a new field in a transformer for the result of this calculation and made it Numeric 10. What is your derivation? What are the datatypes of the fields used?
-craig

"You can never have too many knives" -- Logan Nine Fingers
mczern
Premium Member
Premium Member
Posts: 80
Joined: Thu Jan 20, 2005 8:38 am
Location: Atlanta, GA
Contact:

Post by mczern »

chulett wrote:So... you've added a new field in a transformer for the result of this calculation and made it Numeric 10. What is your derivation? What are the datatypes of the fields used?
Correct... I'm not sure if the transformer '-' can be overloaded to use 2 timestamps. The calculation I attempted was a simple subtraction of 2 timestamp defined values... Is there a function that can be used? I could not find one.

src1.END_SLOT_DT - src1.SLOT_DT
Mike Czerniawski
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I honestly don't know how to do timestamp math in PX. I was just hoping to lay the groundwork with some basic questions so that when the PX people who actually use the product and know what they're doing wander by, they can get right to work. :wink:

You may end up needing to break the date from the time and handle the differences separately for all I know.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... and divide seconds by 60 to get minutes. :wink:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

D'oh! :oops: :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply