Need to calculate 5th and 15th business day each month (with exceptions) in MS Access

Greeting Experts!
I’m looking to query/calculate when a report is due.
I have two monthly reports, one due on the 5th business day and the second on the 15th business day of every month for the next 4 years.
One problem is that our office works a 9/80 schedule (9 hours a day with every other Friday off).  So I made a table tblCalendarCodes and a tblDates.
Calendar CodesI  assigned every single day for the next four years with a connecting FK to tblCalendarCodes. I figured that would help me count R “regular days” but most sql and vba loops I’ve seen requires a startdate and enddate to calculate the dates. Anybody have any other functions or ideas? My tables are attached.
Workdays.zip
LVL 1
Gemini GVBA & Database ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
This query will do:

SELECT 
    tblDates.CalendarID, 
    tblDates.CalendarDate, 
    tblDates.Description, 
    tblDates.WorkHours, 
    tblDates.CodeID, 
    tblDates.WeekDayID, 
        (Select Count(*) 
        From tblDates As T 
        Where 
             T.CodeID=2 And 
             DateDiff("m",T.CalendarDate, tblDates.CalendarDate)=0 And 
             T.CalendarDate<=tblDates.CalendarDate) AS 
    BusinessDays
FROM 
    tblDates
WHERE 
    (((tblDates.CodeID)=2) AND 
    (((Select Count(*) From tblDates As T 
    Where 
        T.CodeID=2 And 
        DateDiff("m",T.CalendarDate, tblDates.CalendarDate)=0 And 
        T.CalendarDate<=tblDates.CalendarDate))=5 
        Or 
        ((Select Count(*) From tblDates As T 
        Where 
             T.CodeID=2 And 
             DateDiff("m",T.CalendarDate, tblDates.CalendarDate)=0 And 
             T.CalendarDate<=tblDates.CalendarDate))=15));

Open in new window

ee1.PNG
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gemini GVBA  & Database ProgrammerAuthor Commented:
Wow thanks you have saved me again! :)
0
Gustav BrockCIOCommented:
You are welcome!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.