Counting the number of working Mondays

B

Box666

I use

=HowManyWD("01/10/2002","31/12/2002",2)

to count the number of (in this case) Mondays between two dates. I need
to make allowances for Bank Holidays, so I only count the number of
true working Mondays between 2 dates. Does anybody know a way to do
this.

with thanks

Bob
 
D

Douglas J. Steele

You'd need to have a table that contains the holidays, then check for each
Monday to see whether that day exists in the table.

Assuming your holiday table is named Holidays, and contains a field named
HolidayDate (the full date for each holiday), you could use this to
determine how many Monday holidays fall between the two dates, and then
subtract that from the number you already know:

DCount("*", "Holidays", _
"(HolidayDate Between #01/01/2002# And #12/31/2002#) AND " & _
"WeekDay(HolidayDate) = 2")

BTW, assuming you're using the code from
http://www.mvps.org/access/datetime/date0011.htm, you should be using

=HowManyWD(#01/10/2002#,#12/31/2002#,2)

And yes, I recognize that you've got your Short Date format set to
dd/mm/yyyy through Regional Settings. The problem is, Access is picky about
when it chooses to recognize that! You'll likely find that when you type
#12/31/2002#, VBA will rearrange it for you. You may find it informative to
read Allen Browne's "International Dates in Access" at
http://www.allenbrowne.com/ser-36.html or what I had in my September, 2003
"Access Answers" column in Pinnacle Publication's "Smart Access" (You can
download the column, and sample database, for free at
http://www.accessmvp.com/DJSteele/SmartAccess.html)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top