Getting the first Monday after the third Friday

clip art of 
 a double-quote character

Question

I have seen on this site how to get the the third Friday of the month:

select quote_date
FROM table
 where  datename(weekday, quote_date) = 'Friday'
and datepart(day, quote_date)>=15 and datepart(day, quote_date)<=21;

How would I get the first Monday after this third Friday?

asked 2021-08-12 by Ivan


Answer

"The first Monday after the third Friday" could be rewritten as "Three days after the third Friday."

So once you identify the third Friday (via any method), it’s just a matter of adding 3 days. Something like: DATEADD(DAY, 3, ThirdFriday).

This is also a great use case for a Calendar table, which you can read more about here, here, and here.

Using your original query from your question, and assuming this gives you your desired results for "third Friday", then you can do something like this:

SELECT ThirdFriday                 = quote_date,
       FirstMondayAfterThirdFriday = DATEADD(DAY, 3, quote_date)
FROM table
WHERE  datename(weekday, quote_date) = 'Friday'
AND datepart(day, quote_date)>=15 
AND datepart(day, quote_date)<=21;

answered 2021-08-12 by Andy Mallon