Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:13:41+00:00 2026-06-02T19:13:41+00:00

I have a datetime column in my query and I want to do a

  • 0

I have a datetime column in my query and I want to do a CASE in this query.

IF the column DateDelivered is not null, then shows the date, else, show the string ‘Pendent’
how can I do that ?

CASE WHEN DateDelivered IS NOT NULL THEN DateDelivered ELSE 'Pendent' END AS DateDelivered 2

I got this error

Conversion failed when converting date and/or time from character string.

Whole query

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  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:13:44+00:00Added an answer on June 2, 2026 at 7:13 pm

    You’re trying to convert ‘Pendent’ to be a DateTime, because it’s going to convert all of the data to be the same data type. Also, if you’re just checking for NULL, you can use ISNULL or COALESCE. Try this:

    ISNULL(CAST(DateDelivered AS VARCHAR), 'Pendent')
    

    You can also specify your format for DateDelivered:

    ISNULL(CONVERT(VARCHAR, DateDelivered, 101), 'Pendent')
    

    See more options for 101 here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In mysql database i have this column called: Name: Date Type: datetime I have
I have this table: ID(INT) DATE(DATETIME) Under the DATE column there are a lot
I have this query SELECT currency_code, SUM(CASE WHEN TYPE = 'buy'THEN to_amount END )
I have a datetime column called 'last_login'. I want to query my database to
I have a datetime column in db that I want to transform into a
I have a table with a datetime column. Into this column I have written
I have a table [Product] with a column [CreateTime] datetime null, and is has
I have a datetime column in SQL Server that gives me data like this
I have a DateTime column. I want to extract all records, lets say, from
I have a column, it's time is 'DATETIME'. I want to output it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.