Search This Blog

March 21, 2014

SQL Query: Get the correct Fiscal Year and Quarter

Today I need to compare the data accuracy between 2 tables in SQL Server 2008 R2. There is one interesting scenario of Fiscal Year and Quarter for me to validate. The first quarter of a fiscal year starts on October 1 every year.  

For example,

Q4 (FY 2013): July –September, 2013

Q1 (FY 2014): October -December, 2013

Q2 (FY2014):  January –March, 2014

Q3 (FY2014):  April –June, 2014

Q4 (FY2014):  July –September, 2014

Actually, we can use datapart and case when  in SQL query easily.

After that, here is the expected result. 

No comments: