PHP: Search MYSQL database between datetime but use the date only? -


i have column in mysql stores datetime so:

2017-08-18 08:59:53 2017-08-18 07:59:00 

i can search database , return results between datetime column so:

$from = date("y-m-d h:i:s", strtotime($_get['from'])); $to = date("y-m-d h:i:s", strtotime($_get['to']));  $sql1="select * `table` mydate>='$to' , mydate<='$from'"; 

this works fine long search this:

2017-08-18 08:59:53 

but need able search this:

2017-08-18 

and still same result when search.

i don't want use time in search string/query.

try mysql date() function like:

$sql1="select * `table` date(mydate)>='$to' , date(mydate)<='$from'"; 

mysql date() function returns date part datetime column in default y-m-d format.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -