Time Calculations

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

Hello everyone. I am trying to calculate time from time
in to time out then get a total. It works fine when
calculating from example 7AM to 10PM but if you try to
calculate total hours from 11PM to 7AM it give me some
weird time. Can anyone please give me the appropriate
thing to do or code to use to make this work. Please.
Thanks in advance!!

Justin
 
Hello everyone. I am trying to calculate time from time
in to time out then get a total. It works fine when
calculating from example 7AM to 10PM but if you try to
calculate total hours from 11PM to 7AM it give me some
weird time. Can anyone please give me the appropriate
thing to do or code to use to make this work. Please.
Thanks in advance!!

Justin

An Access Date/Time field is stored as a Double Float count of days
and fractions of a day (times) since midnight, December 30, 1899. 7 am
is stored as 0.291666666666667 and 11pm as 0.958333333333333; if you
subtract them you get either plus or minus 0.6666666666666. Either
value converts to #12/30/1899 16:00:00#, because of the odd way Access
handles negative date numbers.

You can use DateDiff() to calculate the difference in time between any
two date/time values, in any unit from seconds to years - see
DateDiff() in the VBA online help. Note that if you're assuming that
7am is eight hours later than 11pm, THAT ASSUMPTION IS WRONG - since
both times are on December 30, 1899, 7am is actually 16 hours EARLIER
than 11pm. If you want to cross midnight you would do better to store
both the date and time in the field - #06/08/2004 07:00:00# is in fact
eight hours later than #06/07/2004 23:00:00#.
 
-----Original Message-----
Hello everyone. I am trying to calculate time from time
in to time out then get a total. It works fine when
calculating from example 7AM to 10PM but if you try to
calculate total hours from 11PM to 7AM it give me some
weird time. Can anyone please give me the appropriate
thing to do or code to use to make this work. Please.
Thanks in advance!!

Justin
.
Try putting the hours in as a 24 hour clock and [time to]-
[time from]
 
Back
Top