Christian Moen Christian Moen -4 years ago 96
MySQL Question

Mysql date select from string

i've issue I try this query, do not return any rows. just 0 rows. Even tho there is data matching the request..

select * from repairshop_reservations where date = DATE_FORMAT("11/06/2017 20:00:00", '%d/%m/%Y %H:%i:%s"');

Currently my content of the selected table look like this
Content of table

The data value of column Date is datetime

Answer Source

you could use str_to_date in this way you can control the proper formatting of the date when you don't use the standard mysql format

select * from repairshop_reservations 
where date = str_to_date('11/06/2017 20:00:00', '%d/%m/%Y %H:%i:%s');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download