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. 


March 19, 2014

Fixed the issue: Invalid Column Name appears in SQL Server Management Studio

Today I used SSMS to select  new columns in SQL query and  it showed invalid column Name ‘XXXXX’.  But running the query has no issue at all.


After looking into this interesting issue, it is easy to fix it.


Just click Edit-> Intellisense-> Refresh Local Cache and  you are all set.