Oracle – Number of Weekdays Between Two Dates

Hey everyone,

Just a quick post on how to select the number of weekdays between two dates:

SELECT temp_tbl.days
--SELECT COUNT(temp_tbl.days)
FROM (          
        SELECT (TRUNC(TO_DATE ('01/08/2012', 'DD/MM/YYYY'), 'dd') + LEVEL - 1) days
        FROM DUAL
        CONNECT BY LEVEL <= TO_CHAR(TO_DATE('10/08/2012', 'DD/MM/YYYY') - TO_DATE('01/08/2012', 'DD/MM/YYYY'))
     ) temp_tbl
WHERE TO_CHAR(temp_tbl.days, 'D') >= 2
      AND TO_CHAR(temp_tbl.days, 'D') <= 6

Leave a Reply