https://plsqlquery.blogspot.com/2019/07/function-number-of-days-between-two.html
create or replace function skip_sat_sunday_f(P_INV_REC_DATE in date ,P_CHECK_DATE in date ) return number is
v_num number ;
begin
select
count(*) into v_num
--mydate ,to_char(mydate,'Day')
from
(
select trunc (add_months (sysdate,-24),'YY') -1 + level as mydate from dual
connect by level <= (select trunc (add_months (sysdate ,48),'YY') - trunc (sysdate,'YY') from dual)
)
where to_char(mydate,'Day') in ('Saturday ','Sunday ')
and (mydate) between to_Date(P_INV_REC_DATE) and to_Date(P_CHECK_DATE);
return v_num;
exception
when others then
v_num:=0;
return v_num;
end ;