I am trying to create an SQL statement for MYSQL to retrieve records that fall between a date range. I would like the records to come back that includes the two dates that specify the range. At the moment this is not happening. Please can someone advise?
MY SQL-PHP:
$fromDate = '21-SEP-2018';
$toDate = '29-SEP-2018';
$sql = "SELECT * FROM myTable WHERE zapDocUserId='$USER_ID' AND dateUpload BETWEEN \"$fromDate\" AND \"$toDate\" ORDER BY dateUpload DESC";
$result = $mysqli -> query($sql);
The records that I get back do not include ones with dates 21-SEP-2018 and 29-SEP-2018. I would like it to be included.
'21-SEP-2018'is not MySQL date format. What is the datatype for yourdateUploadcolumn ? I suspect that it is string type.