SQL Server - Calculate fiscal month for the Calendar Year.

Asked By Charvi Sanghavi on 10-Aug-15 04:01 PM

My organization follows the calendar year from Jan 1st to Dec 31st every year.  But for reporting purposes we go by the fiscal month of the calendar year.

Our fiscal month starts on the first Wednesday of every calendar month and ends on the last Wednesday of the calendar month except for every Quarter end i.e. for March 31, June 30, Sept 30 and Dec 31 of the year the fiscal month ends on the last day of that respective quarter.  I need a function or a query that calculates the fiscal month for any given date of the form mm/dd/yyyy e.g. 10/25/2012.