Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display HH:MM:SS greater than 24 hours?

Status
Not open for further replies.

SR24

Programmer
Jan 14, 2005
19
0
0
US
I'm looking for some help on displaying a Time in military time format that is greater than 24 hours. I have a report which calculates a total number of seconds an agent is logged into their system. I then use the following formula to convert the number of seconds to military time:

numbervar input := Sum ({@Duration},{d_agent_define.lname});
numbervar hours;
numbervar minutes;
numbervar seconds;

hours := int(input/3600);
minutes := int(remainder(input,3600)/60);
seconds := remainder(remainder(input,3600),60);

Time(hours,minutes,seconds);

Although rare, if an employee forgets to log out, the sum of their duration may be greater than 24 hours. If this happens, the formula generates an error stating "Hour must be between 0 and 23", which causes the report to die at this point. As an example, an agents total duration in seconds is 89,238. Is there any way to display this as 24:47:18?

Thanks in advance!
 
Since that isn't a valid time value, don't use a time function, use a totext:

totext(hours, "0") + ":" + totext(minutes, "00") + ":" + totext(seconds, "00");

Check my FAQ as well:

faq767-3543

-k
 
If you just want to display the results, then

totext(hours,0,"")+":"+totext(minutes,0,"")+":"+totext(seconds,0,"")

The time function forces the proper units to be used.

Cheers,
-LW
 
Thanks. I used synapsevampire's formula which works great. A quick question though. I noticed the 2 formulas posted were slightly different. What's the difference between the two?

totext(hours, "0") + ":" + totext(minutes, "00") + ":" + totext(seconds, "00");

vs.

totext(hours,0,"")+":"+totext(minutes,0,"")+":"+totext(seconds,0,"")

Thanks again!
 
Kids formula was built to display 0 decimal points, and the "" states no thousands separator, which isn't required here.

Mine just uses a literal mask for the output, a bit simpler here.

-k
 
Thanks! Just wondering since I noticed a slight difference and wanted to know since I am a bit of a novice.

SR24
 
Check out your help file for the totext, it has lots of parameter choices.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top