Sundays in 2013

Kirthiga
Posted by Kirthiga under Sql Server category on | Points: 40 | Views : 1411
Declare @StartDay date, @EndDay date
Set @StartDay='2013-01-01'
Set @EndDay='2013-12-31'

;with cte(Date) as
(
select @StartDay
union all
select DATEADD(D,1,Date) from cte where Date < @EndDay
)
select [Date],DATENAME(W,Date)[Day] from cte where DATENAME(W,Date)='sunday' option (MAXRECURSION 400)

Comments or Responses

Login to post response