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 format

Status
Not open for further replies.

rhammond

Programmer
Dec 9, 2002
21
US
I have a field where I have a time value that is displayed in Seconds. I need to display it as HH:MM:SS. I've been looking and looking through the help text and the knowledge base on Crystal's site, and can't find anything...anyone know how to do this?
 
I found it! Here's the formula (from crystal's knowledge base...was buried in another function):

local numbervar RemainingSeconds;
local numbervar Hours ;
local numbervar Minutes;
local numbervar Seconds;

//divide the @TotalSeconds by 3600 to calculate hours. Use truncate to remove the decimal portion.
Hours := truncate({Agent_Skill_Group_Half_Hour.TalkInTimeToHalf} / 3600);
//
RemainingSeconds := {Agent_Skill_Group_Half_Hour.TalkInTimeToHalf} - (Hours * 3600);//subtract the hours portion to get //RemainingSeconds
//Divide RemainingSeconds by 60 to get minutes. Use truncate to remove the decimal portion.
Minutes := truncate(RemainingSeconds/60);
//subtract the Hours and Minutes and what is left over is seconds.
Seconds := {Agent_Skill_Group_Half_Hour.TalkInTimeToHalf} - (Hours * 3600) - (Minutes * 60);

//format the hours, minutes, and seconds to hh:mm:ss
totext(Hours,"00") + ":" + totext(Minutes,"00") + ":" + totext(Seconds,"00")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top