7 Replies Latest reply: May 15, 2014 9:58 AM by RickR _

# Help needed with a time conversion

I use Monarch to extract info from mainframe performance reports. The time can be as granular as microsecs. The report time field is 10 chars long and varies from:

hh:mm:ss.t to m.ss.ttttt

The CharToSec function only seems to work to a limited extent ie; 2 positions for the fractions of a second.

Any ideas?

Thank you

• ###### Help needed with a time conversion

Hi Rick,

I think Todd has indicated the way that an output can be achieved but I suspect your problem will now be getting the INPUT right..

I have not experimented yet but I think you would need to find a way to create a value for the Chartoseconds result that goes beyond its 2 decimal place limit. So make a chartoseconds calculation but then add on the partial seconds left off.

Does that make any sense to you?

Grant

[size="1"][ November 28, 2005, 10:26 PM: Message edited by: Grant Perkins ][/size]

• ###### Help needed with a time conversion

Yes, that's it. it worked up to 2 positions, but not past that.

BTW Todd, thank you. I did try it and for example:

Input was 4.16:19.34 ( 4 hrs, 16 min, 19.34 secs) becomes 11:33:39.34000

Thanks again

• ###### Help needed with a time conversion

Originally posted by RickR:

Yes, that's it. it worked up to 2 positions, but not past that.

BTW Todd, thank you. I did try it and for example:

Input was 4.16:19.34 ( 4 hrs, 16 min, 19.34 secs) becomes 11:33:39.34000

Thanks again /b[/quote]Rick,

Does that mean you have the solution or that you are still seeking it?

Grant

• ###### Help needed with a time conversion

Sorry for the confusion. I am still seeking a solution.

Thank you

Here are a couple of examples of the field:

4:16:19.34 ( 4 hrs 16 min 19.34 secs) CharToSec gives me 15379.34

8:46.08569 ( 8 min 46.08569 secs ) gives me a (NULL)

• ###### Help needed with a time conversion

Hi Rick,

I think it’s the variable input that is causing CharToSeconds to fail.  An alternative would be to split the timestring using RSplit and multiplying the sections accordingly.

i.e.

val(rsplit(input,3,":",1))+

val(rsplit(input,3,":",2))*60+

val(rsplit(input,3,":",3))6060

This gives :-

[font="courier"]input             output

4:16:19.34     15379.34

8:46.08569     526.08569[/font][/quote]Is that what you need?

Cheers

Steve

• ###### Help needed with a time conversion

Originally posted by Steve Caiels:

I think it’s the variable input that is causing CharToSeconds to fail.  /b[/quote]I think you are right (yet again) Steve and your suggestion seems to be the way to go. I was looking for something similar but seeking to find the remainder partial seconds that Chartoseconds does not use and simply adding them back to the final result or the Timespan.

However in playing around (V8.01) I discovered that ChartoSeconds does not seem to understand a character field which appears to have more than 2 digits after the decimal point. So even going adding the hours value to the string still produces a null calculation if there are more than 2 decimal places for the seconds.

Here's what I get:

[font="courier"]time             time secs     Disp as Timespan

4:16:19.34     15379.34      04:16:19.34000

8:46.08569

4:16:19.34     15379.34      04:16:19.34000

0:08:46.08569

0:08:46.08     526.08        00:08:46.08000

8:46.08             31568         08:46:08.00000

/font[/quote]My interpretation could be wrong of course - I have not performed an exhaustive test - but if it is correct then it makes your RSPLIT solution just about the only way to go I reckon.

Grant

[size="1"][ November 29, 2005, 06:52 AM: Message edited by: Grant Perkins ][/size]

• ###### Help needed with a time conversion

Steve, the RSPLIT does the trick. Thank you for the help. Thank you too Grant.