SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SP that generates list of sub-date ranges
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

phrankbooth
Posting Yak Master

USA
141 Posts

Posted - 05/16/2012 :  18:46:14  Show Profile  Reply with Quote
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

India
47151 Posts

Posted - 05/16/2012 :  19:42:11  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000