Results 1 to 4 of 4
  1. #1
    Masterfinn is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    7

    Query DateDiff calculation excluding weekends

    Here is what I currently have setup:



    Table: myOrders_tbl
    Fields:
    OrderID
    DateOpened
    DateClosed

    I then have a Form "myOrders_frm" which allows us to choose 2 dates and then it will provide us a count of all the orders that were 'closed' between those dates that were open for 10days or less

    In my Form i have the calculated field linked to a Macro with the following criteria:
    Dcount("[OrderID]","qryDays")

    Then my query "qryDays" has this:
    Field DateClosed
    Critiera >= firstdate AND <= seconddate


    Field DateDiff("d", DateOpened, DateClosed)
    Critiera >=10

    ** i know some of the above syntax is incorrect but i just simplified it

    This is all working correctly and it produces a count of all the orders that were closed in 10 days or less from when they were opened. The problem is that if an order was opened one week and then closed the next this qry will calculate the weekends as part of the 10 days.
    I woud like to somehow alter this qry to run the datediff but exclude the weekends.
    So basicly just count weekdays for the 10 day count.

    Is is possible, and if so how would go about doing this?

    Thanks!!!

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Doug has a function here that might work for you:

    http://www.pacificdb.com.au/Support/...nfunctions.htm

    Other solutions I've seen involve custom functions that account for holidays and weekends.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Masterfinn is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    7
    Thanks for the quick reply. I took a look at that site and was able to setup my Datediff so that it will now calculate only weekdays. I did some testing with it and it appears to be working correctly.

    Thanks again,
    MF

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, glad it worked for you.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. calculation in a query
    By elmartinez in forum Queries
    Replies: 3
    Last Post: 02-12-2010, 03:23 PM
  2. Replies: 4
    Last Post: 02-08-2010, 11:17 AM
  3. Excluding data in a query
    By lpdds in forum Queries
    Replies: 1
    Last Post: 12-16-2009, 08:06 PM
  4. IIF() in a query calculation
    By bbylls in forum Queries
    Replies: 4
    Last Post: 12-03-2009, 04:42 PM
  5. Query Calculation
    By kellyd in forum Queries
    Replies: 5
    Last Post: 08-31-2009, 11:14 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