How to get the Nth weekday of a month from a calendar table
Posted on 2015-02-03
I have a calendar table (seems to be the best practice for other stuff I'm doing)
I have a need to select the top n records for the nth day in a month
SO from today if I need the top 5 second Tuesdays I would expect to get
In my table I have the day number ie a Monday is 2, and month ie feb is a 2 also.
If this cant be done in a query I could add another row to the table of day ordinal in a month, then the query would be simple, but how would I do that, The calendar currently holds 10 years worth of dates.
I'm using SQL server 2008