Mysql – How to select date of only today from datetime column in thesql

MySQL

I have table that have column of datetime that have value like 2017-01-13 17:01:56. Such values will have more than hundreds in a day like ordering in a restaurant. Now I want to select the orders that applied only today or date from datepicker. I don't know how to write the WHERE condition. My database is MySql and I do on c# with WPF.

Thanks.

Best Answer

Date format is YYYY-MM-DD

SET @dt = '2017-01-03 00:00:00';
SELECT * FROM some_table
WHERE datefield >= @dt AND datefield < (@dt + INTERVAL 1 DAY);