时间:2021-07-01 10:21:17 帮助过:14人阅读
/* 查询一段日期内的全部礼拜天 @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
Sql Server 查询一段日期内的全部礼拜天
标签:结束 track content sql declare data time start pos