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

Calculate Average Time

Status
Not open for further replies.

Bell1991

Programmer
Aug 20, 2003
386
US
I need to be able to calculate the average time it takes to fill out a form. I am capturing the start and end time.. But when i attempt to do an average on it - it says it is not allowed.. I am storing them as datetime fields.

avg(dtEndDate - dtStartDate)
 
Here's a runnable example that will give you two ways to do what you want... cut-n-paste the code below into a prg file and execute it.

Code:
RAND(-1)
CREATE CURSOR crsTimes (start T, end T)
FOR lnCounter = 1 TO 100
	INSERT INTO crsTimes (start, end) ;
		VALUES (DATETIME() - INT(1000 * RAND( )), DATETIME())
ENDFOR
CALCULATE AVG(End - Start) TO lnAverageSeconds
?lnAverageSeconds
BROWSE

*!* Or
SELECT AVG(End - Start) FROM crsTimes INTO CURSOR crsAvg
BROWSE

boyd.gif

SweetPotato Software Website
My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top