I have read many posts with answers concerning Mysql queries using BETWEEN none of which I can get to work with my data.
In my case, I have a data table which has two cols both of which hold data as a DateTime. I am trying to right a query that returns a row(s) of data WHERE RoomToDateTime is BETWEEN two other DateTime fields. Example:
RoomToDateTime = "2018-09-10 17:00:00"
$FromDateTime = "2018-09-09 08:00:00" //User selected date and time
$ToDateTime = "2018-09-10 16:00:00" //User selected date and time
The query:
SELECT *
FROM Conf
WHERE RoomToDateTime BETWEEN '".$FromDateTime ."' AND '".$ToDateTime."'
This query returns no data when I know that there is a record where RoomToDateTime does contain "2018-09-09 10:00:00".
This works with dates only (excluding the time part). Can anyone see why the query does not work or am I going about this completely wrong.
Many thanks in advance for your time and helpful comments.