Hi
You will give the
First and
Last Date as an Input, It'll list all the dates between the range... Correct ?
Declare @FirstDate DateTime,
@LastDate DateTime,
@Days Int
Select @FirstDate = '2011-04-05',
@LastDate = '2011-04-11',
@Days = DATEDIFF(Day, @FirstDate, @LastDate) - 1
;With CTEs
As
(
Select 1 [Day]
Union All
Select [Day] + 1 From CTEs Where [Day]<@Days
)
Select CONVERT(Varchar(10),DateAdd(Day,[Day],@FirstDate),20) [Date] from CTEs
Go
Result...
Date
--------------
2011-04-06
2011-04-07
2011-04-08
2011-04-09
2011-04-10
Cheers
Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions
Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator