Figuring Time card hours across Midnight

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

We have a time card program set up that we are using. Problem is that if we
start one day and work past midnight when it figures the hours it flips them
as being on one day. Is there a way to set up the expression in order to make
this work. The expression we are using is:
Expr1: ((CDbl([clockin])-CDbl([clockout]))*-24)

I am just learning to use acces so any explanations would need to be basic.
Also can anyone explain what that expression does do? Thank you for your help
Rick
 
Assuming that you're storing the date and time in the clockin and clockout
fields, just use the DateDiff function to calculate the elapsed time in
minutes:

MinutesWorked: DateDiff("n", [clockin], [clockout])

Then you can manipulate this result into hours and fractions of hours by
dividing by 60, etc.
 
We aren't currently storing the date with the clockin/clocvkout as we usually
enter in both times at the end of the job. We have talked about starting to
do that though if there is no other way to get this to work.
Rick

Ken Snell said:
Assuming that you're storing the date and time in the clockin and clockout
fields, just use the DateDiff function to calculate the elapsed time in
minutes:

MinutesWorked: DateDiff("n", [clockin], [clockout])

Then you can manipulate this result into hours and fractions of hours by
dividing by 60, etc.

--

Ken Snell
<MS ACCESS MVP>

Maestro196 said:
We have a time card program set up that we are using. Problem is that if we
start one day and work past midnight when it figures the hours it flips them
as being on one day. Is there a way to set up the expression in order to make
this work. The expression we are using is:
Expr1: ((CDbl([clockin])-CDbl([clockout]))*-24)

I am just learning to use acces so any explanations would need to be basic.
Also can anyone explain what that expression does do? Thank you for your help
Rick
 
Using combination of date and time is the best way to do this.

However, assuming that a work time period will never exceed 24 hours, you
can use an expression similar to this to calculate the elapsed time in a
query's calculated field:

WorkedTimeInHours = ([clockout] - [clockin] - ([clockout] < [clockin])) * 24

The above expression subtracts the start time from the end time, and then
tests to see if the end time is "earlier" than the start time; if it is, it
subtracts -1 (essentially, adds 1) to the resulting calculation (1 = 24
hours in ACCESS time). It then multiplies the result by 24 to get the hours.

--

Ken Snell
<MS ACCESS MVP>


Maestro196 said:
We aren't currently storing the date with the clockin/clocvkout as we usually
enter in both times at the end of the job. We have talked about starting to
do that though if there is no other way to get this to work.
Rick

Ken Snell said:
Assuming that you're storing the date and time in the clockin and clockout
fields, just use the DateDiff function to calculate the elapsed time in
minutes:

MinutesWorked: DateDiff("n", [clockin], [clockout])

Then you can manipulate this result into hours and fractions of hours by
dividing by 60, etc.

--

Ken Snell
<MS ACCESS MVP>

Maestro196 said:
We have a time card program set up that we are using. Problem is that
if
we
start one day and work past midnight when it figures the hours it
flips
them
as being on one day. Is there a way to set up the expression in order
to
make
this work. The expression we are using is:
Expr1: ((CDbl([clockin])-CDbl([clockout]))*-24)

I am just learning to use acces so any explanations would need to be basic.
Also can anyone explain what that expression does do? Thank you for
your
help
 
Back
Top