# Find the 5th business day

Hello experts,

In MS Access I need a VBA code to check if today is the 5th business day of the month.

Thanks.
###### Who is Participating?
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.

Commented:
Wont it always be the 7th of the month?  Unless you are including bank/public holidays.. Are you counting these?
0
Commented:
Could also be the 5th or 6th, if the month starts on a Sun or Mon.  I'm trying to work out the logic.
0
Commented:
ahh. Sure is

0
Commented:
Check out this link that contains a formula to find the nth particular weekday of any month:

0
Commented:
Here's what I came up with:

If today is Friday, and the date is the 5th or the 6th, it's the 5th bus day of the month.
If the above is not true, but today is the 7th (and it's not a weekend), it's the 5th bus day of the month.
Otherwise, it's not the 5th bus date.

To use the function below, call

SomeBooleanVariable = IsFifthBusDay(DateYouWantToCheck)

It will return True if it is the 5th bus day, False otherwise.

-----

Private Function IsFifthBusDay(YourDate as Date)
If WeekDay(YourDate) = vbFriday AND (Day(YourDate) = 5 OR Day(YourDate) = 6) Then
IsFifthBusDay = True
ElseIf Day(YourDate) = 7 AND WeekDay(YourDate) <> vbSaturday AND WeekDay(YourDate) <> vbSunday
IsFifthBusDay = True
Else
IsFifthBusDay = False
End If
End Function
0

Experts Exchange Solution brought to you by

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

Author Commented:

Thanks,
Will try it.

0
Commented:
Still not sure what to do about holidays.  Perhaps we could create a table, then have the user enter holidays at the beginning of the year.  (Unless these are available somewhere.)  We'd need to figure out what to do from there, though.
0
Author Commented:

That is good,
I will worry about the holidays later. Will just test that functionality.
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
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.