Answer the question
In order to leave comments, you need to log in
How to compare a date in a selection from a database?
I have a date stored in the database in this form 2016-02-04 12:30:00
and
there is a variable that is compared with it in this form 2016-02-04 , that is, without time
For them to be equal
Answer the question
In order to leave comments, you need to log in
datecolumn >= '2016-02-04' and datecolumn < '2016-02-04' + interval 1 day
You can try to do STR_TO_DATE('2011-12-21 02:20pm', '%Y-%m-%d %h:%i%p') and compare numbers already, which is more convenient, although it depends on the column type, if line - it will definitely be bad. If possible, it's better not to store the date in this form, IMHO.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question