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

Time Difference Formula

Status
Not open for further replies.

rhoneyfi

MIS
Apr 8, 2002
200
US
I use the following formula to convert a field "total seconds' to a 'days hours minutes seconds' format. I actually want to it to display 'days hours minutes'...no seconds... How can I modify the formula so that if the formala does incounter a 'seconds' amount of , lets say, 45, it will round up the minute?
Example: total seconds is = 295
I want the formula to produce the result: "three minutes" (since 295 seconds is actualy 2 minutes 55 seconds). I don't want the formula to say "2 minutes"
********************
WhilePrintingRecords;
NumberVar TotalSec := {@Date_Diff_Seconds};
NumberVar Days := Truncate (TotalSec / 86400);
NumberVar Hours := Truncate (Remainder ( TotalSec,86400) / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);

Totext ( Days, '00', 0,'') + ' days '+
Totext ( Hours, '00', 0,'') + ' hours '+
Totext ( Minutes,'00', 0,'') + ' minutes '
 
Probably something after your minutes calc like:

If Remainder(TotalSec,60) >= 30 then
Minutes := Minutes +1

-k
 
WhilePrintingRecords;
NumberVar TotalSec := {@Date_Diff_Seconds};
NumberVar Days := Truncate (TotalSec / 86400);
NumberVar Hours := Truncate (Remainder ( TotalSec,86400) / 3600);
NumberVar Minutes := Round(Remainder ( TotalSec,3600) / 60,0);

Totext ( Days, '00', 0,'') + ' days '+
Totext ( Hours, '00', 0,'') + ' hours '+
Totext ( Minutes,'00', 0,'') + ' minutes '

I think you just need to change the last truncate to round as above.

-LB
 
lbass,
Your 'Round' code worked great. Thanks so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top