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!

Seconds to hours, help 3

Status
Not open for further replies.

kovas

Technical User
Aug 6, 2002
88
US
I am trying to convert seconds into hours, mins, secs.

{@Test}
ToNumber (244800)

{@Test2}
WhilePrintingRecords;
NumberVar TotalSec := {@Test};
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,'')

The result is 20:00:00

244,800 secs should be 68 hours, anyone have any idea whats wrong here?

thanks
 
We do something similiar with time value conversions, try the following, it will display as 68:00:00.

WhilePrintingRecords;
NumberVar TotalSec := {@Test};

numberVar vhr := int({@Test}/3600);
numberVar vrem := remainder({@Test},3600);

numberVar vmin := int(vrem/60);
vrem := remainder(vrem,60);

numberVar vsec := int(vrem);

Totext ( vhr, '00', 0,'') + ':'+
Totext ( vmin,'00', 0,'') + ':'+
Totext ( vsec,'00', 0,'')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top