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

时间:2015-11-20 23:01:40   收藏:0   阅读:1781

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

原文:http://www.cnblogs.com/gaocong/p/4982501.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!