Wednesday 31 July 2013

SQL Query to find No. of working day in a month

SQL Query to find No. of working day in a month

SELECT * FROM
(
    SELECT TRUNC(sysdate,'MM')+ROWNUM -1 DATES FROM
    (
    SELECT 1
    FROM Dual
    GROUP BY CUBE (2, 2, 2, 2, 2)
    )
    WHERE ROWNUM <= ADD_MONTHS(TRUNC(sysdate,'MM'),1) - TRUNC(sysdate,'MM')
)
WHERE TO_CHAR( DATES, 'DY') NOT IN ('SAT','SUN');

No comments:

Post a Comment