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

Average Time Query

Status
Not open for further replies.

omgm1ke

Programmer
Joined
Feb 27, 2007
Messages
8
Location
GB
I have come stuck with averaging a column with type of Time.

I know there is a function AVG() that I can use to filter the average of a column, however, this brings back an integer.

Is there any way to return the average in time format (IE 00:00:00)?

BACKGROUND INFO:

SELECT `estimatedTime`
FROM job_sheet;

Returns,

01:00:00
21:30:00
01:00:00

The data type is time, and the default is 00:00:00.
 
Have you tried?
Code:
SELECT CAST( AVG(estimatedTime) AS TIME )
FROM job_sheet
 

SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(estimatedTime)))
as avg_time
FROM job_sheet


r937.com | rudy.ca
 
Thanks r937, your query worked a charm!

rac2, your query brought back NULL, but thanks anyway.
 
Thanks for the report. Rudy is good, no doubt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top