I was working on a project where I need find the number of weekdays within two dates and I thought it is good to share with you all.
Please find the below query to find the number of weekdays within two dates.
SELECT ((SYSDATE+30-SYSDATE)-2*FLOOR((SYSDATE+30-SYSDATE)/7)- DECODE(SIGN(TO_CHAR(SYSDATE+30,'D')-
TO_CHAR(SYSDATE,'D')),-1,2,0)+DECODE(TO_CHAR(SYSDATE,'D'),7,1,0)-
DECODE(TO_CHAR(SYSDATE+30,'D'),7,1,0)) Weekday
FROM Dual
I hope this will be helpfull.
Comments
Post a Comment