title: mysql adddate no weekends
body: <p>first of all i know that this has been asked before, and there are some really good answers, but not 100% correct, since my reputation is low I can't post comments.
  My question is how to add days in MySQL excluding weekends, for example
  the day 1/8/2018 if we add 20 days the results should be 1/29/2018, most of the forum answers are like the following</p>
  
  <p>SELECT <code>StartDate</code>,<code>Expected Date</code>,DATE_FORMAT( DATE_ADD(<code>StartDate</code>, INTERVAL <code>Expected Date</code> +</p>
  
  <p>IF(
          (WEEK(<code>StartDate</code>) &lt;> WEEK(DATE_ADD(<code>StartDate</code>, INTERVAL <code>Expected Date</code> DAY)))
          OR (WEEKDAY(DATE_ADD(<code>StartDate</code>, INTERVAL <code>Expected Date</code> DAY)) IN (5, 6)),<br>
          IF(  <code>Expected Date</code> >0, 2, -2 ),
          0)
      DAY
      ) ,  '%y-%m-%d') as FinalDate from <code>table</code>,</p>
  
  <p>THIS WORKS but for low numbers where it will encounter just one weekend, I do change the formula to accept minus add days. 
  I know the tricky part is around IF(  <code>Expected Date</code> >0, 2, -2 ), where it add or delete more days if its weekend, but cant find a way to figure it out if there are more than 1 weekend in between.</p>
  
  <p>i hope I make my self clear and some could help me.</p>
  
  <p>Similar post but not 100% right
  <a href="https://stackoverflow.com/questions/38522170/mysql-add-working-days-to-date">Here</a></p>
  
  <p>Thank you</p>