ACCESS TIME DIFFERENCE

  • Thread starter Thread starter Mr. Quartz
  • Start date Start date
M

Mr. Quartz

Anybody here that have a running / tested code that can determine the time
difference.. For example: an employee timein: 11:30pm and timeout: 2:30am
the difference must be 3 hrs...
 
Anybody here that have a running / tested code that can determine the time
difference.. For example: an employee timein: 11:30pm and timeout: 2:30am
the difference must be 3 hrs...

DateDiff() will do this. However, if you're spanning midnight, you're really
best off storing the date and the time together; 2:30AM December 21 is *after*
11:30PM December 20, but it's *before* 11:30PM December 21!

Access Date/Time fields are stored as a number, a count of days and fractions
of a day (times) since midnight, December 30, 1899. As such you can get into
some contortions if you're storing just time portions.

Open the VBA editor by typing Ctrl-G, select Help, and search for DateDiff.
You can use "h" for integer hours (but 10:59am to 11:01am counts as a whole
hour!), or

DateDiff("n", [In], [Out]) / 60.

to calculate hours and fractions of an hour (assuming you've fixed the date
part by including the dates in both fields).

John W. Vinson [MVP]
 
Back
Top