Select "Date" from "Datetime" Column in MySQL
630
If you would like to select only "date" from "datetime" column, you can use DATE() function of MySQL, inside the query with an easy way.
Example:
"Date" column is storing values as "datetime" format like: 2020-01-01 00:00:00
This way you can not directly match values if you are trying to fetch records with "2020-01-01" dates because of time values are conflicting exact match.
Query:
There are a few more alternative to select without time value, but I think this one is the easiest.
DATE() function of MySQL in WHERE condition:
Example Usage:
SELECT * FROM 'TableName' WHERE DATE('ColumnName') = DATE('2020-01-01');
SELECT * FROM 'TableName' WHERE DATE('ColumnName') = DATE('2020-01-01');
If you are looking for consultation, fill the Contact Form below.
Be alone, that is the secret of invention; be alone, that is when ideas are born.
Haluk YAMANER
Founder @ Future Software UAE
Founder @ Future Linux
Click here for more about me »