title: Why CAST('20140904 23:59:59.999' AS datetime) equals '2014-09-05 00:00:00.000'?
body: <p>Try it for yourself, maybe it is somehow related to my environment:</p>
  
  <p><strong>The query:</strong></p>
  
  <pre><code>SELECT CAST('20140904 23:59:59.999' AS datetime)
  </code></pre>
  
  <p><strong>The result:</strong></p>
  
  <pre><code>2014-09-05 00:00:00.000
  </code></pre>
  
  <p>Please explain this phenomenon.</p>
  
  <p><strong>UPDATE</strong>: Alex mentioned that datetime values are rounded to increments of .000, .003, or .007 seconds. The question is why?</p>