title: Compare a date string to datetime in SQL Server?
body: <p>In SQL Server I have a <code>DATETIME</code> column which includes a time element.</p>
  
  <p>Example:   </p>
  
  <pre><code>'14 AUG 2008 14:23:019'
  </code></pre>
  
  <p>What is the <strong>best</strong> method to only select the records for a particular day, ignoring the time part?</p>
  
  <p>Example:  (Not safe, as it does not match the time part and returns no rows)</p>
  
  <pre><code>DECLARE  @p_date DATETIME
  SET      @p_date = CONVERT( DATETIME, '14 AUG 2008', 106 )
  
  SELECT *
  FROM   table1
  WHERE  column_datetime = @p_date
  </code></pre>
  
  <p><em>Note: Given this site is also about jotting down notes and techniques you pick up and then forget, I'm going to post my own answer to this question as DATETIME stuff in MSSQL is probably the topic I lookup most in SQLBOL.</em></p>
  
  <hr>
  
  <p><strong>Update</strong> Clarified example to be more specific.</p>
  
  <hr>
  
  <p><strong>Edit</strong> Sorry, But I've had to down-mod WRONG answers (answers that return wrong results).</p>
  
  <p>@Jorrit: <code>WHERE (date&gt;'20080813' AND date&lt;'20080815')</code> will return the 13th and the 14th.</p>
  
  <p>@wearejimbo: <em>Close, but no cigar!</em> badge awarded to you. You missed out records written at 14/08/2008 23:59:001 to 23:59:999 (i.e. Less than 1 second before midnight.)</p>