/* 查询一段日期内的全部礼拜天 @startdate 開始日期 @enddate 结束日期 */ declare @startDate datetime declare @endDate datetime declare @week varchar(20) set @startDate = '20150101' set @endDate = '20151231' while @startDate <= @endDate begin set @week = DATENAME(weekday, @startDate); if (@week = '星期六' or @week = '星期日') begin select DATENAME(YEAR, @startDate) as "year", @startDate as "day" end set @startDate = @startDate + 1; end
时间: 2024-10-12 20:07:46