计算两个日期之间的工作天数

来源:互联网 发布:淘宝凌美钢笔店铺推荐 编辑:程序博客网 时间:2024/05/22 16:47

返回A,B两个员工聘用日期之间的工作天数

create table test as

select level as id

from dual

connect by level<500;


select sum(case

                   when to_char(min_hd+test.id-1,'DY','NLS_DATE_LANGUAGE=American') in(‘SAT’,'SUN')

                   then 0

                   else 1

                   end) as 工作天数

from (select min(hiredate) as min_hd,max(hiredate) as max_hd

          from tab

          where name in('A','B')) x,test

where test.id<=max_hd-min_hd+1;

0 0
原创粉丝点击