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!

Formating Int and Mod Functions

Status
Not open for further replies.

ascension25

Vendor
Jan 30, 2003
1
GB
I am trying to convert seconds into a string ("hh:nn:ss") I found one way below but when I tried to use Int and Mod functions, see bottom I return the Hours, Minutes and Seconds with two decimal places and cannot find out how to format the functions.

numbervar hours;
numbervar minutes;
numbervar secs;
numbervar wait;
wait:=Sum ({Time1)}, { Employee});
hours:=int(wait/3600);
minutes:=int((wait-(hours*3600))/60);
secs:=(wait-(hours*3600)-(minutes*60));
totext(hours,"00")+":"+totext(Minutes,"00")+":"+totext(secs,"00")

-------------------------------------

This returns '1.00:23.00:6.00' where {Time} = 4986
Int ({Time}/3600) & ":" & Int ({Time}/60) & ":" & ({Time} Mod 60)

Many thanks to anyone who reads this.

Or maybe you know a better way? Any help would be appreciated.
 
Try this, it works fine for me.

NumberVar TotalSec := {@Seconds};
NumberVar Hours := Truncate (Remainder ( TotalSec,86400) / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);
NumberVar Seconds := Remainder ( TotalSec , 60);

Totext ( Hours, '00', 0,'') + ':'+
Totext ( Minutes,'00', 0,'') + ':'+
Totext ( Seconds,'00', 0,'')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top