两个日期相减,计算工作天数(不含周六周日)

两个日期相减,计算工作天数(不含周六周日)

 

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);

posted @ 2023-08-11 11:25  yongqi-911  阅读(134)  评论(0编辑  收藏  举报