SQL Generate full calendar list of dates
846398Mar 10 2011 — edited Mar 10 2011I'm trying to generate a list of dates given the current date. For example, for today, March 10, I want the dates from March to be listed. This is for a Calendar application and because of that I need to fill out the calendar with pre and post days. For example, for March, the following dates would need to be included:
02/17/2011
02/28/2011
All the dates in March...AND
04/01/2011
04/02/2011
If you look on a Calendar, it usually starts on a Sunday...depending on where you are. I need all dates returned to account for the extra days before and after the month in question. Do that make sense?
Any help is greatly appreciated.
This is what I would like to see:
Order DateValue WeekDay Day Month
1 02/27/2011 1 27 2
2 02/28/2011 2 28 2
3 03/01/2011 3 1 3
4 03/02/2011 4 2 3
5 03/03/2011 5 3 3
6 03/04/2011 6 4 3
7 03/05/2011 7 5 3
8 03/06/2011 1 6 3
9 03/07/2011 2 7 3
10 03/08/2011 3 8 3
11 03/09/2011 4 9 3
12 03/10/2011 5 10 3
13 03/11/2011 6 11 3
14 03/12/2011 7 12 3
15 03/13/2011 1 13 3
16 03/14/2011 2 14 3
17 03/15/2011 3 15 3
18 03/16/2011 4 16 3
19 03/17/2011 5 17 3
20 03/18/2011 6 18 3
21 03/19/2011 7 19 3
22 03/20/2011 1 20 3
23 03/21/2011 2 21 3
24 03/22/2011 3 22 3
25 03/23/2011 4 23 3
26 03/24/2011 5 24 3
27 03/25/2011 6 25 3
28 03/26/2011 7 26 3
29 03/27/2011 1 27 3
30 03/28/2011 2 28 3
31 03/29/2011 3 29 3
32 03/30/2011 4 30 3
33 03/31/2011 5 31 3
34 04/01/2011 6 1 4
35 04/02/2011 7 2 4