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!

average time calc

Status
Not open for further replies.

harrybosch

Programmer
Feb 27, 2001
8
NL
Hello everybody,

I've created a report that calculates the average flying time of an airplane for a particular destination in a given period of time. These averages are calculated in minutes and are formatted to fit in the HH:MM format by the following formula:

(=&quot;Average Flight Time: &quot;+FormatNumber(Truncate((Average(<Actual Flight Time (min.)>)/60),0), &quot;00&quot;) + &quot;:&quot; + FormatNumber(Mod(Average(<Actual Flight Time (min.)>),60),&quot;00&quot;)

However in some occasions, for example:

Total amount of minutes: 7908
total amount of flights: 44

The report turns up with average time 2:60, while it should be 3:00. Is there any way this can be prevented?

Thanks,

brgds,

Harry
 
Hello Harry,

I have no data to check whether the following will work, but what if you use the ceil-function to round the average-figure of 179.727272..... (7908/44) to 180.
Even if this works , it would not be a valid conversion, because if it had been 179,1313, you would have wanted 2:59 instead of 3:00.
This could then be achieved by performing a check before you use the ceil-function by doing a check on the decimal part of the average:

truncate(avg,2)- truncate(avg,0) > .50

If this expression is true, you use the ceil-function, otherwise the floor-function (or ceil()-1)

Probably some expressions need some tuning, but perhaps this would be of some use
 
Blom,

Thanks for the reply. I'll try and see if it works.

Regards,

Harry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top