title: CASE statement using DateTime column
body: <p>I have a datetime column in my query and I want to do a CASE in this query.</p>
  
  <p>IF the column DateDelivered is not null, then shows the date, else, show the string 'Pendent'
  how can I do that ?</p>
  
  <pre><code>CASE WHEN DateDelivered IS NOT NULL THEN DateDelivered ELSE 'Pendent' END AS DateDelivered 2
  </code></pre>
  
  <p>I got this error</p>
  
  <pre><code>Conversion failed when converting date and/or time from character string.
  </code></pre>
  
  <p>Whole query</p>
  
  <pre><code>SELECT  San_Imovel.Imovel_Id ,
          San_Chave.DataHoraPegou ,
          CASE WHEN San_Chave.DateDelivered IS NOT NULL THEN San_Chave.DateDelivered
               ELSE ISNULL(CAST(San_Chave.DateDelivered AS VARCHAR), 'Pendent')
          END AS DateDelivered2 ,
          San_Usuario.NomeCompleto + ' - ' + sc.Apelido AS Nome ,
          San_Cliente.NomeCompleto AS NomeCliente ,
          San_Credenciada.Apelido ,
          San_Cliente.Cliente_Id ,
          San_ChaveImovel.QuantidadeChave
  FROM    San_ChaveImovel
          JOIN San_Chave ON San_ChaveImovel.Chave_Id = San_Chave.Chave_Id
          JOIN San_Credenciada ON San_Chave.Credenciada_Id = San_Credenciada.Credenciada_Id
          JOIN San_Imovel ON San_ChaveImovel.Imovel_Id = San_Imovel.Imovel_Id
          JOIN San_Usuario ON San_Chave.Usuario_Id_Responsavel = San_Usuario.Usuario_Id
          JOIN San_Credenciada sc ON San_Usuario.Credenciada_Id = sc.Credenciada_Id
          JOIN San_Cliente ON San_Chave.Cliente_Id = San_Cliente.Cliente_Id  
  </code></pre>