/* 查询一段日期内的所有礼拜天 @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-11-08 21:44:11