当前位置: 代码迷 >> MySQL >> MYSQL 两日期之间的工作日(去掉周六日,不考虑节假日)
  详细解决方案

MYSQL 两日期之间的工作日(去掉周六日,不考虑节假日)

热度:93   发布时间:2016-05-05 16:35:03.0
MYSQL 两日期之间的工作日(除去周六日,不考虑节假日)

select (floor(days/7)*5+days%7  
    -case when 6 between wd and wd+days%7-1 then 1 else 0 end  
    -case when 7 between wd and wd+days%7-1 then 1 else 0 end ) INTO str
from  
(select datediff(e,s) as days,weekday(s)+1 as wd) as a;    
    ELSE

    select (-(floor(days/7)*5+days%7  
    -case when 6 between wd and wd+days%7-1 then 1 else 0 end  
    -case when 7 between wd and wd+days%7-1 then 1 else 0 end)  ) into str
from  
(select datediff(s,e) as days,weekday(e)+1 as wd) as a;    
    end if;
RETURN str;
END
select first_func('2015-11-17','2015-11-20')

  相关解决方案