Computing.Net > Forums > Office Software > Help with time arithmetic in Access

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help with time arithmetic in Access

Reply to Message Icon

Name: lawrencebenson
Date: February 5, 2006 at 00:28:48 Pacific
OS: Windows XP
CPU/Ram: na
Comment:

I am putting together an Access data base to help streamline my office.

It is a catering company so the tables I have created are EventInformation, PayGrades, EmployeeInformation, and TimeSheet. Right now I am trying to setup a Query to calculate "hours" based off the "clockin" and "clockout" fields entered under the TimeSheet table so then I can multiply it by the hourly rate. How do I set this up? What if the clockout time is on the proceeding day?

Help is greatly appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: February 5, 2006 at 03:08:28 Pacific
Reply:

Normal calculating time differences is simple a matter of subtracting one from the other, that is providing the fields are defined as Time/Date fields. Time/Date are stored as floating point numbers.

Providing the clock on time and clock of time are in the same 24 hour period, then there is no problem. Time calculations completely ignore the date.

Problems can arise when the clock-in time and clock-out time span midnight - that is they occur on two different days.

In that is likely to happen you first need to determine if out time is less than in time. If it is, then there is a midnight in the middle.

You will then need to take the difference between in and out and subtract the sum from 24, or 23 hours, 59 minutes and 59 seconds to give you the correct number. 23 hours, 59 minutes and 59 seconds = 0.999988425925926 = the number of ticks since the previous midnight.


Stuart


0

Response Number 2
Name: lawrencebenson
Date: February 5, 2006 at 10:34:16 Pacific
Reply:

I am assuming I would have to set up an IF statement when "Timein">"Timeout". THEN 2400-([Timein]+Timeout])?

How do I set that up?

Is there anyway to have a user select a date off a mini calander when entering the time? It is a shot in the dark.


0

Response Number 3
Name: StuartS
Date: February 5, 2006 at 10:53:54 Pacific
Reply:

Not quite

If TimeIn > TimeOut then
time = 23:59:59 - (timein-timeOut)
End if

So is someone clocks in at 22:00 and clock out at 06:00 the following morning they have done an eight hour shift.

22:00 - 06:00 = 16 hours. Not what you want.
However. 24 hours-16 = 8 hours, which is what you want.

You have to use 23:59:59, one second before midnight. 24 hours will equate to midnight which is Zero.

You can select the date using the Date Time picker Active X control

Stuart


0

Response Number 4
Name: lawrencebenson
Date: February 5, 2006 at 12:00:31 Pacific
Reply:

How do I use the date time picker Active X control? Sorry not an Access stud yet.

Thanks again


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Help with time arithmetic in Access

Need help with IF statement in Exce www.computing.net/answers/office/need-help-with-if-statement-in-exce/5152.html

Help with Dates in Excel 2003 www.computing.net/answers/office/help-with-dates-in-excel-2003/8431.html

OLE error in Access 2003 www.computing.net/answers/office/ole-error-in-access-2003/2169.html