title: SQL Server : today is not equal to today
body: <p>Maybe I'm making an obvious mistake but can anyone explain what's going on here? I was running a query where the table's field is datetime and the query I was running was something like</p>
  
  <pre><code>SELECT *
  FROM Table
  WHERE DateTimeColumn &lt;= '20170714'
  </code></pre>
  
  <p>and I noticed the output excluded the records where <code>DateTimeColumn</code> is <code>'20170714'</code> they finished at <code>'20170713'</code></p>
  
  <p>Below I was expecting all 3 IIF to fall into true.</p>
  
  <pre><code>DECLARE @d1 DATE = '20170714'
  
  SELECT IIF(GETDATE() &lt;= @d1, 'GETDATE() Less than or equal to @d1', 'GETDATE() **NOT** Less than or equal to @d1')
  
  DECLARE @d2 DATE = '20170714 11:59:59'
  
  SELECT IIF(GETDATE() &lt;= @d2, 'GETDATE() Less than or equal to @d2', 'GETDATE() **NOT** Less than or equal to @d2')
  
  DECLARE @tomorrow DATE = '20170715'
  
  SELECT IIF(GETDATE() &lt;= @tomorrow, 'GETDATE() Less than or equal to @tomorrow', 'GETDATE() **NOT** Less than or equal to @tomorrow')
  </code></pre>