Using STR_to_DATE in PHP SQL Query

I need to change the format of the date format from datetime to date in the SQL query, I tried:

$sql="SELECT created_by FROM meetings WHERE STR_TO_DATE('date_start', 'Y-m-d')='$CorrectDate'";

but to no avail.

date_start is a field in an SQL table.

Any help is appreciated !!!

+3
source share
1 answer
SELECT  created_by
FROM    meetings
WHERE   date_start >= $correctDate
        AND date_start < $correctDate + INTERVAL 1 DAY

Unlike any solution that includes a function or expression above date_start, it is one-way, i.e. it can use the index efficiently date_start.

+2
source

Source: https://habr.com/ru/post/1789050/


All Articles