取出星期一日期

  • 726
  • 0

取出星期一日期

declare @sd datetime = '20121226'
declare @dd datetime = '20141231'
declare @t table (c1 datetime)

while @sd <= @dd
begin
	if DATENAME(weekday,@sd) = 'Monday' 

	insert into @t values (@sd)
	set @sd = DATEADD(day,1,@sd)
end

SELECT convert(VARCHAR(8),c1,112) FROM  @t