你的位置:首页 > 数据库

[数据库]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')