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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert seconds to HH:MM:SS

Status
Not open for further replies.

RevItUp

MIS
Oct 8, 2003
7
US
Is there a straight forward way to convert seconds to Hours, Minutes, Seconds? For example 3729 seconds to 1:02:09. I have a line item that's already an average number of seconds based on a number of phone calls. To summarize it I must first multiply the the avg seconds by the number of calls for each line and then subtotal the number of calls and number of seconds and then divide the number of seconds by the number of calls. The trick is to express this result in HH:MM:SS as an avg on a summary line.
Thank you in advance for your help.
 
This will give you HH:MM, you can mod it to get your SS

WhilePrintingRecords;

global numbervar iTotalTime;

local numbervar iHours := 0;
local numbervar iMinutes := 0;
local stringvar sTimeSpent := "00:00";

if iTotalTime > 0 then
(
iHours := Truncate(iTotalTime / 60);
iMinutes := Remainder(iTotalTime, 60);
sTimeSpent := Right("0" + ToText(iHours,0),2) + ":" + Right("0" + ToText(iMinutes,0),2);
iTotalTimeRpt := iTotalTimeRpt + iTotalTime;
);
sTimeSpent;


Paul Wesson, Programmer/Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top