I am using PHP with MySQL and would like to select rows that have a booking time within 2 hours from now. How do I compare what is in my database with the NOW()
MySQL function?
I have columns pickupDate
in the format yyyy-mm-dd
and pickupTime
in the format HH:mm
(24-hour). I have tried creating a query with NOW()
which returns the a 12-hour time as HH:mm:ss
e.g. 2019-05-24 07:54:06 . I can't figure out how to format this to 19:54, or if I should use a different function instead.
For example, if the current date and time is 24/05/19 19:54:06, I would like to select rows between 19:54 and 21:54 on this date.
My table structure is:
referenceNo VARCHAR(100)
pickupDate DATE
pickupTime VARCHAR(100)