I have two date and time columns in my database. I want to get rows where date is greater than or equal to current date and current time
I have used below query to get result
SELECT DISTINCT
A.appt_fromUser,A.date,A.time,A.appt_styleType,B.*,A.appt_shoutID,A.shout_status
from appoint_db A
INNER JOIN checkedin_db B ON A.appt_id=B.appid
where A.appt_toUser='$userid'
and A.date>='$date'
and InChair='0'
and A.time>='$time'
However this isn’t working as I’d hoped.
Eg, if I have two rows:
2012/05/30 Time:6.00
2012/05/30 Time:13.00
And I query this with date of 2012/05/02 and Time:12:00, it returns only only the row where the time is greater than 12:00
You should only check the time if the date is the same as the one you’re checking against.
You could also concatenate the date and time before selecting. I wouldn’t though (might not work with some locales).