title: Error converting data type varchar to float
body: <p>Searched and searched on SO and can't figure it out<br>
  Tried CASTING each field as FLOAT to no avail, convert didn't get me any further<br>
  How can I get the below case clause to return the value stated in the THEN section?</p>
  
  <p>Error:
  Msg 8114, Level 16, State 5, Line 1
  Error converting data type varchar to float.</p>
  
  <p>section of my SQL query that makes it error:</p>
  
  <pre><code>When cust_trendd_w_costsv.terms_code like '%[%]%' and (prod.dbo.BTYS2012.average_days_pay) - (substring(cust_trendd_w_costsv.terms_code,3,2)) &lt;= 5 THEN prod.dbo.cust_trendd_w_costsv.terms_code
  </code></pre>
  
  <p>average_days_pay = float<br>
  terms_code = char</p>
  
  <p>Cheers!</p>