I have some dates that I would like to filter with SQL.

I want to be able to pass a flag to say keep all the FIRST Mondays of the months from X date to Y Date.

So essentially, I want to pass in a date and be able to tell if it's the first, second, third, fourth or last Monday (for example) of a given month.

I have already filtered down the months and days and I am currently using DATEPART(DAY, thedate) to check if the day is &lt; 8 then 1 week &lt; 15 2 week etc.... but this is not correct.

So the part I am stuck on is Where IsDateFirstOfMonth(@date)
Where would I start to write the function IsDateFirstOfMonth?
Any help much appreciated


Question: Is it copyright infringement by US copyright law if someone else modifies and uses my design?
Answer: Did you have a contract that explicitly stated the agreement you had with the client? That would be ideal. But barring that, verbal agreements can still have some weight.

If you want to pursue this, you really need to get a lawyer involved. I'd suggest consulting a lawyer. They may consult you for free, or perhaps you may have to pay for an hour of their time. Only you can decide if it's worth that.