?
Solved

Disregard weekends in a date query

Posted on 2008-06-16
3
Medium Priority
?
324 Views
Last Modified: 2013-11-28
I have a query that counts the number of days taken to process a particular job in our facility and reports if a particular department has exceeded allotted time. I need this query to disregard weekends.  Currently I'm using criteria thats similar to this:
Query Field: Date()
Criteria: >[Date_Entered_Into_Dept] + 3
In other words report if the Current Date is 3 days or more later than the "Date_Entered_Into_Dept".
Any ideas how I can make this ignore weekends and holidays?

0
Comment
Question by:ckarrow2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21793420
you will need a function to do that and a table for holidays.

Function getWorkDays(vDate1 As Date, vDate2 As Date) As Long
Dim i As Long, dtStart
dtStart = vDate1
i = DateDiff("d", vDate1, vDate2) + 1
Do Until dtStart >= vDate2
    dtStart = dtStart + 1
    Do While Weekday(dtStart) = 1 Or Weekday(dtStart) = 7 _
        Or Not IsNull(DLookup("[Date]", "tbl_Holidays", "[Date]=#" _
             & dtStart & "#"))
            dtStart = dtStart + 1
            i = i - 1
    Loop
Loop
getWorkDays = i

End Function
0
 

Author Comment

by:ckarrow2
ID: 21808879
I hate to be dense... but exactly where do I put this Function?
I understand the holiday table concept tho.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 21821343
place the codes in a module.

to use in a query

select [Date_Entered_Into_Dept],getWorkdays([Date_Entered_Into_Dept],Date()) from tablex
where getWorkdays([Date_Entered_Into_Dept],Date())>3
0

Featured Post

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question