I am trying to select between two dates in PHP and SQL. However, my PHP dates are printed like this:
July 1, 2017
and
July 30, 2017
The problem is, that in the database I am selecting from, the dates is stored like this
yyyy-MM-DD:
2017-07-01
and 2017-07-30
I am trying to make a query, to select between two dates:
SELECT dl.list_id, dl.id, dl.date, dl.list_name, dl.list_supplier, dls.reference, dls.mawb, dls.shipment, dls.kg
FROM driving_lists dl LEFT JOIN
driving_list_shipments dls
ON dl.list_id = dls.list_id
WHERE dl.deleted=0 AND dls.kg > 0 AND dl.date between 'FORMAT(July 01, 2017,'yyyy-MM-DD')' and 'FORMAT(July 30, 2017,'yyyy-MM-DD')'
ORDER BY dl.list_id
So, the problem is with this:
dl.date between 'FORMAT(July 01, 2017,'yyyy-MM-DD')' and 'FORMAT(July 30, 2017,'yyyy-MM-DD')'
How can I select between two dates by converting it to the format, that the database uses?