title: Replacing a calculated field column with a Blank when a NULL is returned?
body: <p>I'm doing a simple query that uses the DateDiff function to find the number of days between the dates. However, with regards to certain instances, I'd like to populate a blank field (not a null). </p>
  
  <p>Something like this is what I currently have, and it seems to work fine (but it populates a null).</p>
  
  <pre><code> [Test (Years)] = CASE WHEN TYPE IN ('A','B') 
   THEN NULL ELSE IsNull(CONVERT(decimal(28,12),
   (DATEDIFF(d,@StartDate,ExpirationDate)))/365,0) END
  </code></pre>
  
  <p>Now if I try something like this... which tries to convert all TYPE A and B to populate a blank, I'll get the following error message: <code>Error converting data type varchar to numeric.</code></p>
  
  <pre><code> [Test (Years)] = CASE WHEN TYPE IN ('A','B') 
   THEN '' ELSE IsNull(CONVERT(decimal(28,12),
   (DATEDIFF(d,@StartDate,ExpirationDate)))/365,0) END
  </code></pre>
  
  <p>Is there a simple thing I'm missing? I've tried doing the calcualtions without converting to a decimal, but it doesn't seem to work. Any ideas? Thanks</p>