title: C# SQL Server compare date with string
body: <p>I have to compare a table field that is a date stored as varchar in the format 'dd/MM/yyyy' with a date value, but the comparison fails. I have exception </p>
  
  <blockquote>
    <p>Conversion failed when converting date and/or time from character string.
    I tried converting the date to compare i nstring, like this </p>
  </blockquote>
  
  <pre><code>string dateFormat = date.ToString("dd/MM/yyyy");
  </code></pre>
  
  <p>and then write the query like this:</p>
  
  <pre><code>string sql = "select * from TB_RICHIESTE where CONVERT(DATE, Date) &lt;= CONVERT(DATE, '" + dateFormat + "')";
  </code></pre>
  
  <p>But I have this excpetion. Someone can help me? Thanks</p>