I am looking for some SQL to determine if the current week is the week that contains the Nth Day of the month.
Example. I want to know if I am in the week that contains the third Friday that will occur this month. Or which week of the month contains the third Friday. Weeks should be defined as starting on a Sunday and ending on a Saturday. So a month that starts on a Saturday would not see it’s Friday until the 4th week, where as a month that starts Sunday – Friday, would see it’s 3rd Friday in the 3rd week of the month.
Not sure if PL/SQL is required for this or not.
You can simply generate the date ranges for the weeks that contain the Nth Day of each month, e.g. the 3rd Friday of each month, with a query like this:
EDIT:
You can create a simple function to check a single date, e.g.: