title: Date conversion doesn't work in where clause
body: <p>I am trying to query against the columns SOE (datetime field) and Answer (varchar field) from a table where NOT ALL Answer values are dates but some of them are. If I remove the datediff from the 'where' clause, I'm able to run the query just fine. But on including it, it errors out saying that <strong>'Conversion failed when converting date and/or time from character string'</strong>. </p>
  
  <p>For context, I'm using SQL Server 2014.</p>
  
  <p>This is what my query looks like:</p>
  
  <pre><code>select ID, 
         convert(datetime, Answer, 121) as Answer, 
         datediff(dd,convert(datetime, 
         Answer, 121), SOE) as Days
  from table
  where Type in (1) and SOE between '2019-01-01' and '2019-03-31'
        and FormLocation = 'M1005_INP_DISCHARGE_DT'
        and PayorType = 'Medicare'
        and Answer &lt;&gt; ' '
        datediff(dd, convert(datetime, Answer, 121), SOE) &lt;= 5
  </code></pre>
  
  <p>Any tips on how to resolve this would be appreciated. </p>