只用一行sql语句,如何把2个日期间的周六日的天数剔除掉。

2024-11-05 18:42:30
推荐回答(1个)
回答(1):

  

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;