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 strongm 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.

jpillonel

Programmer
Dec 17, 2003
61
CH
Hi,

I'm new user of Crystal Reports

We have a field in our helpdesk database that is called "time_spent_sum". This field contain the total spent time in seconds.

How can I convert this field (NUMBER in seconds) to this format: HH:MM or HH:MM:SS ??

Thanks for you help !
 
Thanks for your answer but, when I create this formula I have this message:

" A date is required here" for the 'datediff("s",{call_req.time_spent_sum}

This field is elapsed time in seconds.
 
The first thing in the formula determines seconds from 2 dates, since you already know the number of seconds, just use your field:

numberVar dur := {call_req.time_spent_sum}
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs, "0") + ":" + totext(min, "00") + ":" + totext(sec, "00");

The next thing that *might* get you is if it's stored as a string, if so, use val({call_req.time_spent_sum})

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top