I need to generate records on given start-date, end-date and time frequency(Weekly, Monthly etc.)
Example-1:
- Start Date: 15 Jan 2011
- End Date: 31 Dec 2011
- Frequency: Monthly
Generated Reports:
-
15 Jan – 31 Jan
-
1 Feb – 28 Feb (29 Feb Leap Year)
-
1 March – 31 March
.
.
.
- 4- 1 Dec – 31 Dec
Example-2
- Start Date: 15 Jan 2011
- End Date: 31 Dec 2011
- Frequency: Weekly
Generated Reports:
-
1- 15 Jan – 16 Jan
-
2- 17 Jan – 23 Jan
-
3- 24 Jan – 30 Jan
.
.
.
- 50- 26 Dec – 31 Dec
Same as Quarterly.
Any Help
I think what you’re asking is basically how to loop through months/weeks/quarters.
This should give you a good start to point you in the right direction I hope. You just have to muck around with the built in SQL date functions like
DATEADD, DATEDIFF & DATEPART