Select from SQL tables

Asked

Viewed 28 times

-2

Good morning, everyone! I’m performing the select below:

select * from orcamento 
        where 
        status_orcamento = 'A' 
        and data_conclusao_orcamento > 2021-05-31 

My question is: Information should only come above day 31/05/2021 correct?

  • 1

    put the date in single quotes, I will make the calculation of 2021 minus 5, minus 31

  • This conversion depends on the database used and internal parameters, in addition to the "type" of the column (not being DATE will behavior).

  • Thank you very much, it worked.

1 answer

2

No! SQL is recognizing its "2021-05-31" as a mathematical expression and not as a date. Try:

select * from orcamento 
        where 
        status_orcamento = 'A' 
        and data_conclusao_orcamento > Convert(datetime, '2021-05-31')

Or else, a way not so correct:

select * from orcamento 
        where 
        status_orcamento = 'A' 
        and data_conclusao_orcamento > '2021-05-31' ;

Tell me if it worked!

  • Thank you very much, it worked.

  • @Dhionasrm can only select the "right" for the answer count as correct? Thank you!

  • How can I do that, I’m new to Stackoverflow and I don’t know how to do it.

  • @Dhionasrm On the left side of my answer there should be a visa to confirm that the question has been well answered

Browser other questions tagged

You are not signed in. Login or sign up in order to post.