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

calculate the average for elapsed times

Status
Not open for further replies.

susanna123

Technical User
Jan 22, 2010
79
CA
I have start and end times and have calculated the time elapsed which is difference between start and end time. I would like to calculate the average of the elapsed time.

A formula field has been created for elapsed time.

The code is as follows:

Local NumberVar sec := DateDiff ('s',{@Instance Start Time} , {@Instance End Time}) ;
//sec := 12500 ;
Local NumberVar hrs := Truncate(Remainder(sec,86400)/3600);
Local NumberVar mns := Truncate(Remainder(sec,3600)/60);
Local NumberVar scs := Remainder(sec,60);

ToText(hrs,"00") + ":" + ToText(mns,'00') + ":" + ToText(scs,'00')

I would like to create a formula field to calculate the average of elapsed time. It would show the averages for every elapsed time

Can you show me how this can be done?
Thks.
 
Unless I am missing something: right click on the formula field (once it is added to the report) and select the Summary option, then "average".

(NB: table linking which causes duplicate detail rows can cause this to give false results, so ensure the "Distinct Records" option is checked.)

"Crystal Reports Formulas Explained" is the most advanced book on the market. Currently available with a free 70 page Crystal Reports XI tutorial:
 
Hi Please refer below:


What i'm having trouble is this scenario here:

5 elapsed times:

1. 20 minutes
2. 20 minutes
3. 20 minutes
4. 20 minutes
5. 40 minutes

the average of those 5 times are 24 minutes: 20+20+20+20+40/5

The elapsed time is 40 minutes and total time is 40 minutes

I only want to display the times that are over 30 minutes. In this case row 5 but still be able to show the average time of 24 minutes for the entire report.
I have a parameter created that allows user to select the processing time in seconds. If i filter it just 40 minutes or 40x60 = 2400 in seconds. It will only show row 5 and the average would not be 24 minutes but instead 40 minutes.

Hope this clarifies and helps you to unstand what I'm looking for. Thks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top