--只是加了固定日期,可以根据需求给成变量形式(BY 少年工藤)
-思路:根据日期区间循环判断每一天是周日(1)、周六(7)不变,其他加1
1 DECLARE @DAY DATE,@COUNT INT
SET @DAY=''
SET @COUNT=0
WHILE @DAY<=''
BEGIN
SET @COUNT=@COUNT+(
CASE DATEPART(WEEKDAY,@DAY) WHEN 1 THEN 0
WHEN 7 THEN 0
ELSE 1
END )
SET @DAY=DATEADD(DAY,1,@DAY)
END
SELECT @COUNT