title: Compare dates From - To
body: <p>It seems impossible to learn how date comparison works.<br>
  Php is this, Js is that.<br></p>
  
  <p>I have a HTML table with dates:</p>
  
  <pre><code>2016-02-01 08:16:31
  2016-02-01 18:55:52
  2016-02-02 15:13:41
  ...
  </code></pre>
  
  <p>Now i'd like to build a JS to filter dates out.<br>
  So, i grab dates with jquery as text, and convert it to a dateobj:</p>
  
  <pre><code>$('td.datum').each(  function() {
    //Get this date
    thisDate = new Date( $(this).text() );
  ...
  </code></pre>
  
  <p>Next i use <code>bootstrap-datepicker</code> to choose dates.<br>
  I grab selected dates, and convert them to date obj.<br></p>
  
  <pre><code>dateStart = new Date( $('#dateStart').val() );
  dateEnd = new Date( $('#dateEnd').val() );
  </code></pre>
  
  <p>Now i made a if statement to sort dates:<br></p>
  
  <pre><code>if (thisDate &gt;= dateStart &amp;&amp; thisDate &lt;= dateEnd ) {
    $(this).parent().show();
  }
  else {
    $(this).parent().hide();
  }
  </code></pre>
  
  <p>My problem is now, that if dateStart is <code>2016-01-01</code><br>
  and dateEnd is <code>2016-01-02</code><br>
  Only <code>2016-01-01</code>will be shown.<br>
  I'll have to set <code>dateEnd</code>to <code>2016-01-03</code> to show <code>2016-01-02</code>.<br></p>
  
  <p>Why is that?<br></p>
  
  <p>I thought <code>&lt;= dateEnd</code>in my if statement should involve choosen <code>dateEnd</code>?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My soloution will be:<br></p>
  
  <pre><code>//Add one day to dateEnd to get time rigth (00:00:00)
  dateEnd.setDate(dateEnd.getDate() + 1);
  </code></pre>
  
  <p>I'll add one day to the selected end day.</p>