title: another Conversion failed when converting datetime from character string
body: <pre><code>SELECT Asset.AssetID, AnsMaint.Answer, Convert(datetime, AnsMaint.Answer) as maintasdate
  FROM Asset INNER JOIN 
  AssetAnswer AnsMaint ON AnsMaint.AssetID = Asset.AssetID INNER JOIN  
  AssetField FldMaint ON FldMaint.AssetFieldID = AnsMaint.AssetFieldID 
  WHERE FldMaint.FieldText = 'Maint. Agreement Term' 
  AND ISDATE(AnsMaint.Answer) = 1 
  AND Convert(datetime, AnsMaint.Answer) &lt; DateAdd(d, 145, GetDate())
  </code></pre>
  
  <p>I get the error on the last part of the AND.  If I comment the AND out, it works fine.  My dates in the DB happen to be 10/10/2012 and are valid.  IsDate should weed out anything that is not valid.</p>
  
  <p>In DB the results (when I comment out the last line).  I'm completely stumped.</p>
  
  <pre><code>106 10/10/2012  2012-10-10 00:00:00.000
  115 10/10/2012  2012-10-10 00:00:00.000
  </code></pre>
  
  <p>MORE interesting tidbits.  If I change the last AND line to </p>
  
  <pre><code>AND DateAdd(d, cast(Asset.MaintenanceFreq as int), Convert(datetime, AnsMaint.Answer)) &lt; DateAdd(d, 45, GetDate()) 
  </code></pre>
  
  <p>it works.  If I take out the 2nd parameter (the cast as int) and replace it with a number or a zero, it gives me the same error.</p>
  
  <p>I'm stumped.  Any help would be so much appreciated!</p>
  
  <p>Oh, AssetMaint.Answer is a varchar field in the DB nothing I can do about that.</p>