--不算第一天
SELECT CASE WHEN COUNT(*) = 0 THEN 1
ELSE COUNT(*)
END
FROM master..spt_values
WHERE number BETWEEN 1
AND DATEDIFF(dd, '2016/8/20', '2016/9/7')
AND type = 'P'
AND DATEPART(dw, DATEADD(dd, number - 1, '2016/8/20')) NOT IN ( 1, 7 )
--实际天数
SELECT COUNT(*)
FROM master..spt_values
WHERE number BETWEEN 1
AND DATEDIFF(dd, '2016/8/20', '2016/9/7')
AND type = 'P'
AND DATEPART(dw, DATEADD(dd, number - 1, '2016/8/20')) NOT IN ( 1, 7 )
两个日期之间的天数(工作日)
最新推荐文章于 2020-10-08 21:38:05 发布