Nick Dale Nick Dale - 29 days ago 6
MySQL Question

mySql less than or equal to not accurate

I am trying to search using 2 dates. If the user chooses the same date for both from and to dates I get no results.

This example only gives me results from 2016-10-18 to 2016-10-19:

where (a.date >= '2016-10-18' AND a.date <='2016-10-20')


How do I get it to include the second value?
Also if I have

where (a.date >= '2016-10-18' AND a.date <='2016-10-18')


I get no results at all

I have had similar problems in the past with numerical value ranges

Any help greatly appreciated

Answer

try adding Hour and minute .. the date is form 00:00 and not for 23:59

 where (a.date >= '2016-10-18 00:00 ' AND a.date <='2016-10-18 23:59') 
Comments