Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SP that generates list of sub-date ranges

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2012-05-16 : 18:46:14
Hi,

I've been looking for an SP that generates a list of sub date ranges within a date based on the step parameter passed in. So, if my Date Range is 1/1/2012 to 1/25/2012 and the step param passed in is 10, then it should return a rowset like so:

StartDt, EndDt
1/1/2012, 1/10/2012
1/11/2012, 1/20/2012
1/21/2012, 1/25/2012

If anyone can point me to something that does this or offer some advice, I'd appreciate it.

Thanks.

--PhB

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-16 : 19:42:11
you need a function like below

http://visakhm.blogspot.com/2010/02/generating-calendar-table.html

and add dateadd(dd,10,date) as end date

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -