title: Calculate Number of worked_days in Given month from Deployment data (Mysql/PHP)
body: <p>I am working on Payroll System where an employee can be deployed on projects from <em>any_date</em> to <em>any_date</em>. Sample MySQL table below</p>
  
  <pre><code>id   empid  project_id     start_date                end_date 
  1      1       2        2016-11-05 15:10:22    2016-12-11 15:11:21 
  2      1       3        2016-12-13 15:26:10    2016-12-20 15:29:40 
  3      1       2        2016-12-23 15:31:46    2017-01-18 15:32:35 
  </code></pre>
  
  <p>Now, if I want to calculate the number of days in <strong>given month</strong> worked on all projects, I am using Eloquent which translates to below query(I verified in <code>DB::getQueryLog())</code>:</p>
  
  <pre><code>SELECT 
  *
  FROM
      payroll_project_tracks
  WHERE
      empid = 1
          AND '2016-12-01 00:00:00' BETWEEN start_date AND end_date
          AND '2016-12-31 23:59:59' BETWEEN start_date AND end_date
  </code></pre>
  
  <p>After getting the rows that have deployments of given month (month = Dec 2016 here), I want to calculate Number of Days worked on <em>all projects in a given month.</em></p>
  
  <p>I am getting no results with the above query. Can anyone correct me or let me know if there is some better way of doing this.</p>