title: How to use Where clause with datetime in SQL Server 2008
body: <p>I have written this query:</p>
  
  <pre><code>SELECT * 
  FROM w_tbl 
  WHERE DID NOT IN (SELECT DId FROM tbl_Assign) 
    AND CAST(MeasDateTime AS Date) = @dta 
  ORDER BY 
      CAST(MeasDateTime as DATE) DESC
  </code></pre>
  
  <p>So as you can see I am sending a parametrized query.</p>
  
  <p>So I put <code>24/09/2010 00:00:00</code> for <code>@dta</code></p>
  
  <p>But I get this error: </p>
  
  <blockquote>
    <p>Conversion failed when converting date and/or time from charterer string.</p>
  </blockquote>
  
  <p>I tell you why I am doing this and my purpose:</p>
  
  <p>I have a datetime column, and I want to select/fetch all data by date only (i.e. I don't want to fetch datetime wise, it has to be just according to date) </p>