create or replace function fun_workday(startdate in varchar2,
enddate in varchar2)return number
IS
TOTALVALUE NUMBER;
begin
select count(*) into TOTALVALUE
from ( select rownum rnum
from all_objects
where rownum <= to_date(enddate,'yyyy-MM-dd') -
to_date(startdate,'yyyy-MM-dd')+1 )
where to_char( to_date(startdate,'yyyy-MM-dd')+rnum-1, 'D' )
not in ( '1', '7' );
return TOTALVALUE;
end;
例如:查看7月份的工作日:
select fun_workday('2014-7-1','2014-7-31') from dual;
结果为:23