title: Transact SQL date query returning no results
body: <p>From my code, I call an SP using:</p>
  
  <pre><code>using (var cmd = new SqlCommand("sp_getnotes"))
  {
    cmd.Parameters.Add("@ndate", SqlDbType.SmallDateTime).Value
                    = Convert.ToDateTime(txtChosenDate.Text);
    cmd.CommandType = commandType;
    cmd.Connection  = conn;
  
    var dSet = new DataSet();
    using (var adapter = new SqlDataAdapter { SelectCommand = cmd })
    {
      adapter.Fill(dSet, "ntable");
    }
  }
  </code></pre>
  
  <p>The Stored Procedure itself runs a simple query:</p>
  
  <pre><code>SELECT * FROM tblNotes WHERE DateAdded = @ndate
  </code></pre>
  
  <p>The problem is no records are returned! <code>DateAdded</code> is a <code>smalldatetime</code> column.</p>
  
  <p>When I change the query to the following, it works:</p>
  
  <pre><code>SELECT * FROM tblNotes WHERE CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, DateAdded))) = @ndate
  </code></pre>
  
  <p>Why is this happening? This change affects the entire application and I'd like to find the root cause before getting into changing every single query... The only changes we made are to use parameterized queries and upgrade from SQL Server 2005 to 2008.</p>
  
  <p>TIA.</p>