Select "Date" from "Datetime" Column in MySQL
323

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');
If you are looking for consultation, fill the Contact Form below.
The supreme art of war is to subdue the enemy without fighting. Sun Tzu
Haluk YAMANER - Personal
Contact Form
You must complete Security Verification to submit your form.