Hello,
I'm trying to search a table using a date submitted in a form in the format of YYYY-MM-DD. But the date in the table field is in datetime format of YYYY-MM-DD HH:MM:SS. I'm having trouble trying to compare the date from the form to the datetime field.
This is my query so far:
SELECT punch_id, punch_username, punch_in, DATE_FORMAT(punch_in , '%Y-%m-%d') As compare_date
FROM time_punch
WHERE punch_username = 'colname' AND compare_date = 'searchdate'
ORDER BY punch_in ASC
This would all work fine if I could compare the date submitted in the form(searchdate) against the newly created column "compare_date" as I obviously tried to do in my query. This of course gives me an "Unkown Column - compare_date - In Where Clause" error.
Does anyone know how to compare a YYYY-MM-DD formatted date from a form, to a datetime field?
Thank You.