SQL query to determine Fiscal Week
833855Jan 24 2011 — edited Jan 27 2011Hi Experts,
I need to figure out the fiscal week for a specific datetime field based on the following requirements:
1. A week Starts on Saturday and Ends on Friday.
2. If Feb 1st of a given year is a Saturday, then week 1 will run from February 1st to February 7.
3. If Feb 1st is not on a Saturday, then week 1 starts on the previous Saturday and ends on the first Friday of February
Example 1: February 1st 2011 is on a tuesday so Week 1 will be from Jan 29th (Saturday) to February 4 (Friday). Week 52 of 2011 will be from Jan 21, 2012 (Saturday) to Jan 27, 2012 (Friday)
Example 2: February 1st 2014 is on a Saturday so Week 1 will be from February 1st to February 7.
I am looking for some sql or pl sql to get the week number. Any help will be greatly appreciated