# Amend date function

Hi,

Below is a date function that i use to test to see whether it is the first working day of the month and if it is i do some other stuff.

Can i have this amended so it checks to see if it is the 2nd day of the working day of the month

Thanks
Seamus

Function IsFirstWorkingDay(dt As Date) As Boolean
Dim FirstWorkingDay As Date

FirstWorkingDay = DateSerial(Year(dt), Month(dt), 1)
Select Case Weekday(FirstWorkingDay, vbMonday)
Case 6
FirstWorkingDay = FirstWorkingDay + 2
Case 7
FirstWorkingDay = FirstWorkingDay + 1
End Select

IsFirstWorkingDay = dt = FirstWorkingDay

End Function
###### Who is Participating?

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.

Commented:
hi this will do the trick (it now marks the 2nd working day)

Function IsFirstWorkingDay(dt As Date) As Boolean
Dim FirstWorkingDay As Date

FirstWorkingDay = DateSerial(Year(dt), Month(dt), 1)
Select Case Weekday(FirstWorkingDay, vbMonday)
Case 6
FirstWorkingDay = FirstWorkingDay + 3
Case 7
FirstWorkingDay = FirstWorkingDay + 2
End Select

IsFirstWorkingDay = dt = FirstWorkingDay

End Function
Commented:
Try
``````Function IsSecondWorkingDay(dt As Date) As Boolean
Dim SecondWorkingDay As Date

SecondWorkingDay = DateSerial(Year(dt), Month(dt), 2)
Select Case Weekday(SecondWorkingDay , vbMonday)
Case 6
FirstWorkSecondWorkingDay = SecondWorkingDay + 2
Case 7
SecondWorkingDay = SecondWorkingDay + 1
End Select

IsSecondWorkingDay = dt = SecondWorkingDay

End Function
``````
Author Commented:
I have tried to use these but my syntax in the sub is wrong, i am trying

But am getting argument not optional and its pointing to IsSecondWorkingDay

How can i call this function, ask if its true and if it is, do the sub DoMonthEnd

Thanks
Seamus

If IsSecondWorkingDay = True Then

DoMonthEnd

End If

End If
Commented:
You have to pass it a date to check, just as you did the original function. For example, to check today:

`````` If IsSecondWorkingDay(Date) Then
``````
Author Commented:
Hey guys, both of your functions bring me into DoMonthEnd today, when i shouldnt be coming in today as it is not the 2nd working day of the month. It is the first working day.

SecondWorkingDay

This equals 02/04/2012 in your code Rory when it should be 03/04/2012

Thanks
Seamus
Commented:
``````Function IsSecondWorkingDay(dt As Date) As Boolean
Dim SecondWorkingDay As Date

SecondWorkingDay = DateSerial(Year(dt), Month(dt), 2)
Select Case Weekday(SecondWorkingDay, vbMonday)
Case 1
SecondWorkingDay = SecondWorkingDay + 1
Case 6
SecondWorkingDay = SecondWorkingDay + 2
Case 7
SecondWorkingDay = SecondWorkingDay + 3
End Select

IsSecondWorkingDay = dt = SecondWorkingDay

End Function
``````

Experts Exchange Solution brought to you by