Simple SQL to calculate business days between two dates

Problem

You need a simple SQL to calculate business days between two dates

Solution

select count(1)
from dual,
     (select to_date('30-OCT-2016') end_date, trunc(sysdate) start_date from dual) t
where to_char(t.start_date  + level, 'D') not in (1,7) connect by t.start_date + level <= t.end_date

Replace  to_date('30-OCT-2016') and trunc(sysdate) with the dates you want.
Also utilise last_day functions if you just have a month number or name.


Acknowledgement

http://stackoverflow.com/questions/14898357/calculate-business-days-in-oracle-sqlno-functions-or-procedure

Comments