Tuesday, 10 September 2013

SQL Query - Fetch data based on month & year

SQL Query - Fetch data based on month & year

I want to fetch data based on the following conditions
1) If the current month is September 2013, then I want to fetch data from
Jan 2013 to August 2013.
2) If the current month is Jan 2014, then I want to fetch the data from
Jan 2013 to Dec 2013.
3) If the current month is Feb 2014, then I want to show only Jan 2014 data.
I am using SQL Server 2005 database. Provide some sample queries. Thanks.

No comments:

Post a Comment