Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2004, 04:03 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to avg time in a query

I need to avg a group of times in a column/filed....the time is in hour:minute:seconds format....I thought about converting the times in each record to seconds then adding the seconds together then dividing to get the avg # of seconds...then lastly converting the seconds back to hour:minute:seconds format...I'm not sure if this is the best way or not...if it is I don't know how to go about the conversion to seconds then back....any ideas?
Thanks

 
Old December 8th, 2004, 04:13 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You can create a query that would group by the first column and then average the second column, but the time part makes that a little tricky. What datatype do you have the time column set to in you table?

Mike
EchoVue.com
 
Old December 8th, 2004, 04:59 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Format is long time....has to be as the time is important down to the second....and the time is in ONE column/field and part of 10 seperate records....thanks Mike
 
Old December 8th, 2004, 05:19 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Sounds good, I just tried it on a sample database that I did, with the following query:

SELECT tblTimes.Person, Avg(tblTimes.time) AS AvgTime INTO tblTemp
FROM tblTimes
GROUP BY tblTimes.Person;

This is on a table called tblTimes a column for Person and time. It is a 'Make Table' query, so it will create a new table called tblTemp. In tblTemp, after the query has created it, you will need to go in and change the datatype of the AvgTime field back to Long Time, and that should give you your average. There may be an easier way, but this should get you going for now. As with any query, if you paste the SQL statement in and then go into Design mode, you can tweak it to add fields and change some of the names as needed. Yell if you need more clarification, since I know I tend to ramble on somewhat!

Good Luck

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Query divovsky Access 3 July 25th, 2007 06:24 AM
Using AVG aggregate function with decimal elygp SQL Server 2000 2 May 7th, 2007 09:04 PM
Calculate Avg for cycle time pallavijyo BOOK: Professional Crystal Reports for VS.NET 0 December 10th, 2004 02:34 PM
GROUP BY Avg and Sum pinkandthebrain SQL Server 2000 3 July 14th, 2003 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.