hi, im not sure if this is a simple question but it makes me wonder. i have a field on my database containing date that a service is created. example: date_created 2016-07-07 09:52:15 2016-07-07 08:42:25 2016-07-07 07:22:35 2016-07-06 09:12:15 2016-07-06 07:22:25 On my form i have two datepickers 1. startdate 2. enddate supposed i selected 2016-07-07 from datepicker 1 and 2 it should return data that was created 2016-07-07 here is my query: SELECT * FROM mytable WHERE date_created<=2016-07-07 AND date_created<=2016-07-07 this query does not return any data. can you check what is wrong?
Read through your query, you are always looking for the date created earlier than the selected date. It should be SELECT * FROM mytable WHERE date_created <= 2016-07-07 AND date_created >= 2016-07-07 but it's probably easier to visualise if you put in the variable names from your datepickers $sql = "SELECT * FROM `mytable` WHERE `date_created` <= '{$enddate}' AND `date_created` >= '{$startdate}'";