"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