By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,041 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,041 IT Pros & Developers. It's quick & easy.

Calculating hours

P: n/a
Don
How would I get a query to calculate hours?
if "Starttime" = 10:00AM
and
"Quittime" = 04:00PM
Thanks,
Don.............
Oct 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Don wrote:
How would I get a query to calculate hours?
if "Starttime" = 10:00AM
and
"Quittime" = 04:00PM
Thanks,
Don.............

t1 = #10:00 AM#
t2 = #4:00 PM#
? dateDiff("h",t1,t2)
6
Oct 21 '06 #2

P: n/a
"Don" <vz******@verizon.netwrote in news:Dsq_g.118$gZ2.14
@trndny07:
How would I get a query to calculate hours?
if "Starttime" = 10:00AM
and
"Quittime" = 04:00PM
Thanks,
Don.............
I'll assume that the two fields in question are of type
datetime.
If that assumption is wrong skip these instructions.

Just paste this into a field column of the lower part of the
query design grid.

HoursWorked: datediff("h",[starttime],[Quittime])

Note that this will return the time to the nerest hour.
For a timekeeping system, you need to go to minutes,
MinutesWorked: datediff("n",[starttime],[Quittime])

then show that as hh:mm using an user defined function such as

Public Function minutes2Duration(minutes As Long) As String
Dim hours As Long, mins As Integer
hours = minutes \ 60
mins = minutes Mod 60
minutes2Duration = Format(hours, "#0") _
& ":" & Format(mins, "00")
End Function
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Oct 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.