Results 1 to 3 of 3
  1. #1
    ssworthi is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    22

    DateDif calculation

    My user would like to have lunch of 30 minutes be part of the calculation for hours worked. Is that an IIF calculation or can that work in the
    DateDiff calculation. Thank you so much. This works, I just haven't calculated the 30 minute dedcution if the lunch box is clicked (true).
    Hours: DateDiff("n",[Start time],[End time])/60

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Assuming the "Lunch" is a Boolean field (Yes/No or True/False) and lunch is always 30 minutes, you can work it into the calculation like this:
    Code:
    Hours: DateDiff("n",[Start time],[End time])/60 - IIf([Lunch],0.5,0)

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    I think you want a dateadd function

    DateDiff("n",[Start time],[End time]) gives you total time between the dates, (i.e. lunch included) so you need to deduct 30 minutes if it is not included

    Hours: DateDiff("n",[Start time],dateadd("n",iif(lunchbox=true,0,-30),[End time]))/60

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

Similar Threads

  1. Date Calculation
    By dharsh in forum Access
    Replies: 3
    Last Post: 06-26-2013, 11:19 AM
  2. Date Calculation
    By logle0917 in forum Reports
    Replies: 3
    Last Post: 08-06-2012, 08:18 PM
  3. Date Calculation
    By Lazor78 in forum Forms
    Replies: 4
    Last Post: 01-25-2012, 11:53 AM
  4. Date Calculation
    By mrkaye in forum Forms
    Replies: 5
    Last Post: 11-11-2010, 01:10 AM
  5. Date Calculation ?
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-24-2009, 09:02 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