title: How to count only the working days between two dates?
body: <p>I have the following table called <strong>vacations</strong>, where the employee number is displayed along with the start and end date of their vacations:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id_employe</th>
  <th>start</th>
  <th>end</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1001</td>
  <td>2020-12-24</td>
  <td>2021-01-04</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I am looking for is to visualize the amount of vacation days that each employee had, but separating them by employee number, month, year and number of days; without taking into account non-business days (Saturdays, Sundays and holidays).</p>
  <p>I have the following query, which manages to omit Saturday and Sunday from the posting:</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT id_employee, 
         EXTRACT(YEAR FROM t.Date) AS year, 
         EXTRACT(MONTH FROM t.Date) AS month, 
         SUM(WEEKDAY(`Date`) &lt; 5) AS days 
  FROM (SELECT v.id_employee, 
               DATE_ADD(v.start, interval s.seq - 1 DAY) AS Date 
  FROM vacations v CROSS JOIN seq_1_to_100 s 
  WHERE DATE_ADD(v.start, interval s.seq - 1 DAY) &lt;= v.end 
  ORDER BY v.id_employee, v.start, s.seq ) t 
  GROUP BY id_employee, EXTRACT(YEAR_MONTH FROM t.Date);
  </code></pre>
  <p>My question is, how could I in addition to skipping the weekends, also skip the holidays? I suppose that I should establish another table where the dates of those holidays are stored, but how could my * query * be adapted to perform the comparison?</p>
  <p>If we consider that the employee <strong>1001</strong> took his vacations from <strong>2020-12-24</strong> to <strong>2021-01-04</strong> and we take Christmas and New Years as holidays, we should get the following result:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id_employee</th>
  <th>month</th>
  <th>year</th>
  <th>days</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1001</td>
  <td>12</td>
  <td>2020</td>
  <td>5</td>
  </tr>
  <tr>
  <td>1001</td>
  <td>1</td>
  <td>2021</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>