返回一段时间内的周六日期
CREATE Proc ppp
@begindate datetime,
@enddate datetime
as
declare @satcount int
declare @FirstSat datetime
SET DATEFIRST 1
if (datepart(weekday,@begindate)=7)
set @FirstSat=dateadd(day,6,@begindate)
else
set @FirstSat=dateadd(day,7-datepart(weekday,@begindate)-1,@begindate)
set @satcount=0
while(@FirstSat<=@enddate)
begin
set @satcount=@satcount+1
Select @FirstSat
set @FirstSat=dateadd(day,7,@FirstSat)
end
GO