How to calculate the 2nd Monday of the current Quarter

I have an agent that needs to run the 2nd Monday of every quarter. I am planning on setting it to run weekly and if it’s not the 2nd week of the current quarter, then just exit without doing anything. The hard part is determining if the current date is the 2nd Monday of the current quarter. I’m sure there’s a mathematical way to calculate this but I’m coming up blank. I can get the current quarter and the current week of the year but the current week of the quarter is escaping me.

Any help is appreciated. Thank you.

Subject: How to calculate the 2nd Monday of the current Quarter

Well, when set to run weekly on Monday, first check to see that Month is Either Jan, Apr, Jul, or Oct.

If it is, then you need only know that the day(today) is >7 and < 15.

That is, the second monday will always be on days between 8 and 14 inclusively.

Subject: RE: How to calculate the 2nd Monday of the current Quarter

True, this would work. I was trying to avoid hard coding any dates, including the month, but this wouldn’t be too bad.

Thanks

Subject: RE: How to calculate the 2nd Monday of the current Quarter

Since you said can determine the quarter, can you determine the first day of the quater?

If you can determine the first day or the quarter, then you can determine the day of the week.

From there you can determine the first Monday and then clearly the second monday is just 7 days after that.

dow = weekday ( FirstDayofQtr ) ’ What day is the first day of the Quarter

Adjust = (2 + (7 - dow)) mod 7 ’ First Monday

SecondMonday = Adjsut(firstDayofQtr;0;0;(Adjust+7);0;0;0)

Subject: How to calculate the 2nd Monday of the current Quarter

This is what I finally came up with if anyone is interested.

runAgent = False

If Month(Today) = Int((Month(Today)-1)/3)*3+1 Then

If Day(Today) >7 And Day(Today) <15 Then

	runAgent = True

End If

End If

If Not runAgent Then Exit Sub