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

    date/time field calculations

    I am trying to get the total hours for employees time daily.

    I have the following fields as time fields (medium time) hours mins only.

    starttime
    timeout1
    timein1
    timeout2
    timein2
    finishtime

    Not every time does the employee clock out 2 times but on occasion they do. When they do not those fields are left blank. I used the following to try to get the total hours. I get the correct time if the fileds are not left blank but when no time is entered into any field it does not calcualte right.

    i used
    starttime - 7am
    timeout1 - 12 pm
    time in1 - 1 pm
    timeout2 - blank
    timein2 - blank
    finishtime - 4pm
    should be total of 8 hours.

    I used



    Total Hours: nz(DateDiff("n",[starttime],[timeout1]),0)+nz(DateDiff("n",[timein1],[timeout2]),0)+nz(DateDiff("n",[timein2],[finishtime]),0)

    this only returns total between startime and timout1......what can i do/change to get the total for all fields.

    This is my first time using the date/time field as time. Any help is appreciated. Thanks

  2. #2
    bcofie is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2011
    Posts
    31
    Modify Total hours formule to:

    iif([Starttime] is null OR [timeout] is null, "Whatever you wanna put here", nz(DateDiff("n",[starttime],[timeout1]),0)+nz(DateDiff("n",[timein1],[timeout2]),0)+nz(DateDiff("n",[timein2],[finishtime]),0) )

  3. #3
    donnan33 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    52
    I tried it out. I still get only the total from startime. timeout1..........

  4. #4
    bcofie is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2011
    Posts
    31
    post sample database.

  5. #5
    donnan33 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2011
    Posts
    52
    I got it now thanks anyway.

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

Similar Threads

  1. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 AM
  2. Date/Time Field Query...
    By Coffee in forum Queries
    Replies: 5
    Last Post: 07-05-2011, 11:27 PM
  3. Access 2007 Date/Time Field
    By cdh in forum Access
    Replies: 3
    Last Post: 05-12-2011, 07:11 AM
  4. Access Subquery Max Date/Time field
    By ruci1225 in forum Access
    Replies: 1
    Last Post: 04-08-2011, 07:33 AM
  5. date/time field
    By James890 in forum Database Design
    Replies: 1
    Last Post: 04-18-2007, 07:51 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