两个日期相减,计算工作天数(不含周六周日)
两个日期相减,计算工作天数(不含周六周日)
SET @strdate='20230804';
SET @enddate='20230818';
select DATEDIFF(@enddate, @strdate) + 1-DATEDIFF(ADDDATE(@enddate, INTERVAL 1 - DAYOFWEEK(@enddate) DAY), ADDDATE( @strdate, INTERVAL 1 - DAYOFWEEK( @strdate) DAY)) / 7 * 2 - (DAYOFWEEK(@strdate) = 1)-(DAYOFWEEK(@enddate) = 7);