How many hours have I worked?

  • Thread starter Thread starter Wendy
  • Start date Start date
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
 
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
.
 
Ben and Ken,

You are both lovely lovely people! Thank you.

Wendy
-----Original Message-----
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>

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
.


.
 
Back
Top