Results 1 to 4 of 4
  1. #1
    donnan33 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    52

    Time Calculations

    I have come across a problem i can't seem to fix. I have a database for recording employees hours like a time sheet. I have the following formula used to calculate the total hours worked per day. it works fine until they have time in all 6 fields?????

    TotalHours: (Nz(DateDiff("n",[start time],Nz([time out1],nz([time out2],[finish time]))),0)+Nz(DateDiff("n",Nz([time in2],Nz([time in1],[start time])),[finish time]),0))/60

    I have the following



    Start time
    time out1
    time in1
    time out2
    time in2
    finish time

    They seldom use all 6 but today someone did and it does not calculate properly. for the following times it totals only 4 hours when it should total 5.

    7:05 am - 11:00am - 12:00 pm - 1:00 pm - 4:25 pm - 4:30 pm

    Can anyone help?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    The expression is calculating correctly as designed.

    The first term result is 235 minutes. The second term result is only 5 minutes. Total 240 minutes = 4 hours.

    You need to calculate sum of 3 terms (3 time periods), not 2.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    donnan33 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    52
    Quote Originally Posted by June7 View Post
    The expression is calculating correctly as designed.

    The first term result is 235 minutes. The second term result is only 5 minutes. Total 240 minutes = 4 hours.

    You need to calculate sum of 3 terms (3 time periods), not 2.

    Can you help me with what I would need to add in the formula to make all 3 time periods? I have tried but can;t get it figured out...................To get the correct total of 5 hours?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Maybe:

    (Nz(DateDiff("n",[start time],Nz([time out1],nz([time out2],[finish time]))),0)+

    Nz(DateDiff("n",[time in1],[time out2]),0)+

    Nz(DateDiff("n",Nz([time in2],Nz([time in1],[start time])),[finish time]),0))/60
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. date/time field calculations
    By donnan33 in forum Queries
    Replies: 4
    Last Post: 01-13-2012, 11:58 AM
  2. Time Diff Calculations inside Query.
    By cap.zadi in forum Queries
    Replies: 2
    Last Post: 09-12-2011, 10:04 AM
  3. time calculations
    By venu in forum Database Design
    Replies: 1
    Last Post: 10-23-2010, 12:36 PM
  4. Replies: 4
    Last Post: 01-15-2010, 06:06 AM
  5. Time calculations
    By jimandann in forum Programming
    Replies: 2
    Last Post: 02-18-2009, 12:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums