I am developing a financial application using SQLServer 2008 as database and I want to generate fiscal periods of any year for example
Input : June 2010
Results desired 12 periods from the starting date of June 2010 – May -2011
Period…………….Start…………………………….………..End
1……………………1-06-2010……………………………30-06-2010
2……….1-07-2010………..31-07-2010
And so on untill May 2010 …Actually need to get 12 rows (12 months) starting from any month and output will be the starting date of the month and end would be the last day of the month like for example in my scenario June 2010 – May 2011 ..what will be the query.
Thanks in Advance
Here’s a method using a common table expression to create a list of periods. I’m borrowing @Fosco’s DATEADD approach (thx @Fosco).
There are a number of ways to create your list of periods. See this for examples.