create or replace function fun_workday(sysdate in date)return number
IS
TOTALVALUE NUMBER;
begin
select count(*) into TOTALVALUE
from (select rownum rnum
from all_objects
where rownum <=
add_months(trunc(sysdate, 'mm'), 1) - trunc(sysdate, 'mm'))
where to_char(trunc(sysdate, 'mm') + rnum - 1, 'D') not in ('1', '7')
return TOTALVALUE;
end;
大体意思时创建一个函数fun_workday,传入一个日期类型的参数sysdate ,获取到当前出入日期的第一天和最后一天,然后获取开始至结束日期的工作日,赋值给TOTALVALUE变量进行返回。