Get the number of days excluding weekends using SQL

SELECT COUNT(*)
FROM (
SELECT TRUNC(SYSDATE,'MM') + LEVEL - 1 AS day
FROM dual
CONNECT BY LEVEL <= ADD_MONTHS(TRUNC(SYSDATE,'MM'),1) - TRUNC(SYSDATE,'MM')
)
WHERE TO_CHAR(day,'Dy','NLS_DATE_LANGUAGE=ENGLISH') NOT IN ('Sat','Sun')
 
This query will return the number of days in the current month excluding weekends. You can modify it to get the number of days in any month by changing the SYSDATE function to the first day of the month you want to query.

I hope this blog post was helpful for you. If you have any questions or feedback, please leave a comment below.