How many hours have I worked?

W

Wendy

This is quite simple really, but I just can't figure it
out. I have a field called StartTime and a field called
EndTime, (both formatted at medium date e.g. 10:30am). I
want to create a calculated field (I think I have to do
this in a query) to work out how many hours was worked.
So, if a person started at 9am and finished at 12pm, the
calculated field should say 3 hrs. However, my field says
something like 0.1666678877!! I did [EndTime] -
[StartTime]. What am i doing wrong?

Many Thanks,

Wendy
 
K

Ken Snell

Ben is correct, but instead of using the "h" argument to get hours (which
will be a truncated number -- example, it returns 2 hours for a time
difference of 8:00 am start to 10:30 am end), use the "n" argument
(minutes), and then divide by 60 so that you get fractional hours.

ACCESS stores time as a fraction of a 24-hour day. Thus, 12 hours shows as a
0.5 fraction; 4 hours as a 0.16666666666667 fraction, etc.

--
Ken Snell
<MS ACCESS MVP>

Ben said:
Hi Wendy-
When working with dates in Access you need to use the
built in DateDiff and DateAdd functions to get proper
results.
I believe you would use something like =DateDiff
("h",StartTime,EndTime) to get the difference in hours
between your two dates. you may want to double check
Access help, I've been off in Oracle land for a while.
HTH
Ben
-----Original Message-----
This is quite simple really, but I just can't figure it
out. I have a field called StartTime and a field called
EndTime, (both formatted at medium date e.g. 10:30am). I
want to create a calculated field (I think I have to do
this in a query) to work out how many hours was worked.
So, if a person started at 9am and finished at 12pm, the
calculated field should say 3 hrs. However, my field says
something like 0.1666678877!! I did [EndTime] -
[StartTime]. What am i doing wrong?

Many Thanks,

Wendy
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top