title: System.Data.SqlClient.SQLException: The conversion of a varchar data type to datatime
body: <p>Filter data between two dates I got the following error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: the Conversion of a varchar data
    type to a datetime data type resulted in an out-of-range.</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>con.Open();
  SqlCommand cmd = con.CreateCommand();
  cmd.CommandType = CommandType.Text;
  cmd.CommandText = "SELECT daytime AS DATE, COLUMN_2 AS SHIFT, COLUMN_3 AS 'PART NO',COLUMN_4 AS 'PART NAME',BSNO AS 'BASKET NUMBER',Spare1 AS MATERIAL, CAS6 AS 'CASCADE RINSE 6 TIME (sec)',DRY AS 'DRYER TIME (sec)',TEMP1 AS 'DRYER TEMP (°c)' FROM Table_2 WHERE daytime BETWEEN '" + dateTimePicker1.Value.ToString() + "' AND '" + dateTimePicker2.Value.ToString() + "'";
  cmd.ExecuteNonQuery();
  DataTable dt = new DataTable();
  SqlDataAdapter da = new SqlDataAdapter(cmd);
  da.Fill(dt);
  metroGrid1.DataSource = dt;
  con.Close();
  </code></pre>
  
  <p>I can't solve this error.</p>