Business Days In Current Month
-- Compute cummulative business days in a week excluding weekend 
-- days (SAT, SUN)

WITH q_days AS
(SELECT
   level  day_of_month,
   TRUNC(SYSDATE,'MON')+level-1  month_date,
   TO_CHAR(TRUNC(SYSDATE,'MON')+level-1,'DY') day_of_week, 
   CASE  TO_CHAR(TRUNC(SYSDATE,'MON')+level-1,'DY')
     WHEN 'SAT' THEN  NULL
     WHEN 'SUN' THEN  NULL
     ELSE 1
   END  week_day_idx
 FROM DUAL
 CONNECT BY level <= TO_CHAR(LAST_DAY(SYSDATE),'dd')
)
SELECT
  day_of_month,
  month_date,
  day_of_week,
  CASE day_of_week
     WHEN 'SAT' THEN  NULL
     WHEN 'SUN' THEN  NULL
     ELSE
       SUM(week_day_idx) OVER (ORDER BY month_date)
  END  business_day
FROM  q_days
;

   Cummulative Totals    Business Day Count    Compute Holidays

   Annual Calendar - Summary    Quarter Analysis

Oracle registered trademark of Oracle Corporation.

Last Revised On: December 20th, 2013

  3103