with t as (selectdate'2008-09-01' s,date'2008-09-10' e from dual ) select s,e,e-s+ 1 total_days, trunc((e-s+ 1 )/ 7 )* 5 + nvl(length( replace (substr( '01111100111110' ,to_char(s, 'd' ), mod (e-s+ 1 , 7 )), '0' , '' )), 0 ) work_days from t;
with t as (selectdate'2008-09-01' s,date'2008-09-10' e from dual )
select s,e,e-s+ 1 total_days,
trunc((e-s+ 1 )/ 7 )* 5 + nvl(length( replace (substr( '01111100111110' ,to_char(s, 'd' ), mod (e-s+ 1 , 7 )), '0' , '' )), 0 ) work_days
from t;