Reputation: 35
I have a table called events
and I have two columns called eventDate
and `time´
The point is, I insert the time manually and I would like to get the events today at the time that I have in my column time
EX:
eventDate | time
26-10-2016 | 19:45
I would like to get at 19:45 the event and after two hours dissapear
I tried it but didn't work:
SELECT COUNT(*) FROM events WHERE eventDate = DATE_FORMAT(CURDATE(), '%d-%m-%Y') AND time >= NOW() - INTERVAL 2 HOUR
Forget the COUNT(*) I'm just using it to check
Upvotes: 1
Views: 32
Reputation: 799
Something like this work?
SELECT COUNT(*) FROM events WHERE eventDate = DATE_FORMAT(CURDATE(), '%d-%m-%Y') AND time >= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -2 HOUR),'%H:%i');
Upvotes: 1