title: Calculate Total Working Days of month
body: <p>I have this table where I am specifying Holidays in week. I want to calculate total working days between 2 specific dates using these fields. </p>
  
  <pre><code>CREATE TABLE [tbl_Shift](
  [OffDay1] [nvarchar](25) NOT NULL CONSTRAINT [DF_tbl_Shift_OffDay1]  DEFAULT (N'Sunday'),
  [IsAlternateOffDay2] [bit] NULL,
  [OffDay2] [nvarchar](25) NULL
  )
  
  INSERT INTO [tbl_Shift] VALUES ('Sunday', 'True', 'Saturday')
  </code></pre>
  
  <p>I have this query written but I am not able to get correct days. It should give 23 days as there are 2 holidays in each week and 31 days in total but I'm getting 26 days.</p>
  
  <pre><code>DECLARE @StartDate DATETIME
  DECLARE @EndDate DATETIME
  SET @StartDate = '2018/05/01'
  SET @EndDate = '2018/05/31'
  
  
  SELECT
     (DATEDIFF(dd, @StartDate, @EndDate+1)) -(DATEDIFF(wk, @StartDate, @EndDate))
     -(CASE WHEN IsAlternateOffday2 = 1 THEN 1 END) FROM HRM.tbl_Shift
  </code></pre>