Thanks, Scott
Your code works fine, and much easy to digest ( or learn if you will), amazing.. and thanks again to you and Dwain for sharing this, sure you can read this in books...-)
BTW, Scott
your code produces not correct results if you go beyound 210 days or so, I played with it and found this.
So curious why/where it could happened, tally I think works just fine, it has 100 rows ( for 100 days?), but it still works fine on d,-209 and start breaking on d,-210. (toDD = today = getdate().
You can see looking at toDD for last level, it set to 8/31/13
select 303 Id, DATEADD(d,-210,getdate()) fromDD, getdate() toDD,
datediff(d, DATEADD(d,-210,getdate()), getdate()) period ,3000 prodID
Best to all
M