Results 1 to 4 of 4
  1. #1
    shod90 is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Jan 2016
    Posts
    134

    Question Difference between 2 times in access.

    Dear Gents,
    I have a table which have these coloums ( Employee_IN,Employee_Out,Lastness,TotalWorkingHour s)
    i need to calculate the following:
    1- Employee_Out-Employee_IN = TotalWorkingHours.
    Example:
    17:00 - 09:00 = 8:00


    17:01 - 09:02 = 7:58
    16:57 - 08:39 = 8:18

    2 - Latness , If the Employee came after 09:30 AM should calculate the lateness .
    Example:
    Employee In : 9:45 then the lateness will be 09:45 - 09:30 = 0:15 Mins
    Employee In : 10:15 then the lateness will be 10:15 - 09:30 = 0:45 Mins


    I've tried many times but i honestly failed .

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    have you tried using the datediff function?

    https://www.techonthenet.com/access/...e/datediff.php

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Date/time math is done with DATEDIFF, and DATEADD.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just an FYI,

    09:45 - 09:30 = 0:15 Mins
    Doing this subtraction: 09:45 - 09:30 results in 15 mins (not 0:15 mins)

    0:15 is 15 minutes after midnight.

    Adding two times results in a new time.
    Subtracting two times results in minutes. If you add a zero and the colon ":" in the front of the result, it becomes a time, NOT minutes.

    If you subtract 8:31AM from 4PM you get 7Hrs and 29 min, not 7:29 mins
    4PM is 16:00, so

    16:00 (4pm)
    -8:31 (8:31 am)
    --------
    7 hrs and 29 mins


    I have seen many people struggle with this.....

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

Similar Threads

  1. Replies: 10
    Last Post: 11-08-2014, 07:28 PM
  2. Replies: 5
    Last Post: 09-11-2013, 03:42 PM
  3. SQL Query, find difference in two times.
    By Creaturemagic in forum Queries
    Replies: 7
    Last Post: 05-13-2013, 12:08 AM
  4. Difference between Dates/Times
    By dr4ke in forum Queries
    Replies: 3
    Last Post: 06-26-2012, 06:30 AM
  5. Replies: 3
    Last Post: 08-07-2010, 06:05 PM

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