Elapsed Time function [HH]:MM:SS

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
phipsijuice
Participant
Posts: 12
Joined: Thu Jun 29, 2017 9:48 am
Location: Washington DC

Elapsed Time function [HH]:MM:SS

Post by phipsijuice »

Does DataStage have an Elapsed Time / Duration function? Convert "MM:SS" to "[HH]:MM:SS". Example: "62:15" to "01:02:15". Thanks.
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

There appear to be 2 questions here.

Formatting is easy. Timestamps are just a number under the hood, how you want them to appear as a human readable string is up to you and highly configurable.

Run time depends on what you want really. You can get it after the fact with director or other tools, and you can get it live off the link/stage data with routines to name a couple of approaches.
phipsijuice
Participant
Posts: 12
Joined: Thu Jun 29, 2017 9:48 am
Location: Washington DC

Post by phipsijuice »

Thanks for the reply. It's really just one question. I thought DS might have a function similar to Excel where you can convert "MM:SS" to "[HH]:MM:SS". Obviously I can do the math and formatting through the Transformer Stage but thought there would be a more efficient way?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are those both strings in your job?
-craig

"You can never have too many knives" -- Logan Nine Fingers
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

phipsijuice wrote:Thanks for the reply. It's really just one question. I thought DS might have a function similar to Excel where you can convert "MM:SS" to "[HH]:MM:SS". Obviously I can do the math and formatting through the Transformer Stage but thought there would be a more efficient way?
that was what we are asking. If they are strings, you have to convert from string to time back to string.
if they are times, you can manipulate time and convert once at the end to print it.

Datastage cannot directly do math on strings. It needs either implicit or explicit conversions.
phipsijuice
Participant
Posts: 12
Joined: Thu Jun 29, 2017 9:48 am
Location: Washington DC

Post by phipsijuice »

Yes, they are set up as strings in my jobs.
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

I don't know of a way to avoid conversions. You may be able to let DS convert for you by flowing from text to timestamp to text again in metadata on the columns, or you may decide to do it yourself. The metadata approach will avoid the extra transformer, but the work being done is more or less the same. You don't need a transformer to reshape the strings; many stage allow the transformer string functions inside. If you have one of the stages that allows it, you can do it there.
phipsijuice
Participant
Posts: 12
Joined: Thu Jun 29, 2017 9:48 am
Location: Washington DC

Post by phipsijuice »

That gives me some options. I think we can close this thread. Thank you!
Post Reply