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!

Finding the average of elapsed time

Status
Not open for further replies.

INTP

Technical User
Jan 4, 2003
42
US
I was able to claculated the amount of time that has elapsed between events (stored in the Db as Date/Time format) by using something like

TimeValue ({end time} - {start time})

So I have these 73 items in the details that now appear in a time format (0:37:14 for 37 minutes 14 seconds), but I want to be able to find the average of the the 73 record's elapsed times. I tried to insert summary, but the Average option is not listed.

I am thinking it is not listed because I am not dealing with numbers, but rather a date/time field. I am also thinking that my next step should be to convert the time-formatted fields back into a number, obtain the avrerage and then convert the average in the summary back into a time format so that it doesn't read as a number.

What is the easiest way to do this? Is there an easier way to obtain the same goal that I am overlooking? Thanks for your help.

AJC

 
I would write a formula that captures the elapsed time in seconds using the function DateDiff:

DateDiff ("s",{Elapsed.Start} , {Elapsed.End})

Then to calculate and display the average write a formula as such:
numberVar Hrs;
numberVar Minutes;
numberVar Seconds;

Hrs:= Average ({@ET}) \ 3600;
Minutes:= Remainder (Average ({@ET}),3600 )\60;
Seconds:= Remainder (Average ({@ET}),60);
//
"Average: " + ToText(Hrs,"##0") + " Hrs " + ToText(Minutes,"##") + " Minutes " + ToText(Seconds,"##") + " Seconds "

 
You are correct about changing the field to a number. Change it to seconds by using:
datediff("s",{endtime},{starttime})

Then use this field to get your summary field.
Convert it to hh:mm:ss using:

numbervar tt:= average({of.your.field})
numbervar hours;
numbervar mins;
numbervar secs;

hours:=tt/3600;
mins:=(hours-truncate(hours))*60;
secs:=(mins-truncate(mins))*60 ;
time(truncate(hours),truncate(mins),truncate(secs)) Mike
If you're not part of the solution, you're part of the precipitate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top