SQL Server‎ > ‎

SQL to determine number of working days in a month

Calculates number of working days (i.e. any day that is a Monday to Friday):
(DATEDIFF(dd, beg_date, end_date) + 1)
  -(DATEDIFF(wk, beg_Date, end_Date) * 2)
  -(CASE WHEN DATENAME(dw, beg_Date) = 'Sunday' THEN 1 ELSE 0 END)
  -(CASE WHEN DATENAME(dw, End_Date) = 'Saturday' THEN 1 ELSE 0 END)
Replace beg_date and end_date with the first day of the month and the last day of the month.
Does not factor in holidays.