Monday, October 2, 2017

Exclude Week Ends in the report.



---->>> Below query will exclude Saturday and Sunday exclusion 
                 
SELECT (TRUNC(SYSDATE)-4) DAY1, (TRUNC(SYSDATE)-1) DAY2,
((TRUNC(SYSDATE)-1) - (TRUNC(SYSDATE)-4))-2*FLOOR(((TRUNC(SYSDATE)-1) - (TRUNC(SYSDATE)-4))/7)-DECODE(SIGN(TO_CHAR((TRUNC(SYSDATE)-1),'D')-
        TO_CHAR((TRUNC(SYSDATE)-4),'D')),-1,2,0)+DECODE(TO_CHAR((TRUNC(SYSDATE)-4),'D'),7,1,0)-
        DECODE(TO_CHAR((TRUNC(SYSDATE)-1),'D'),7,1,0) as Working_Days
FROM DUAL


------>>> Below query will exclude Friday and Saturday exclusion

SELECT (TRUNC(SYSDATE)-8) DAY1, (TRUNC(SYSDATE)-1) DAY2,
((TRUNC(SYSDATE)-1) - (TRUNC(SYSDATE)-8))-2*FLOOR(((TRUNC(SYSDATE)-1) - (TRUNC(SYSDATE)-8))/7)-DECODE(SIGN(TO_CHAR((TRUNC(SYSDATE)-1),'D')-
        TO_CHAR((TRUNC(SYSDATE)-8),'D')),-1,2,0)+DECODE(TO_CHAR((TRUNC(SYSDATE)-8),'D'),7,2,0)-
        DECODE(TO_CHAR((TRUNC(SYSDATE)-1),'D'),7,2,0) as Working_Days

FROM DUAL