Reputation: 455
I am trying this:
SELECT matchId FROM Matches where matchDate = CURRENT_DATE + HOUR(CURRENT_TIME) + ':00:00'
but cant get it to work. When I manually do this, it works:
SELECT matchId FROM Matches where matchDate = '2018-01-31 16:00:00'
I tried many variations of, containing CURDATE(), CURRENT_DATE, etc... What am I doing wrong?
Upvotes: 2
Views: 3414
Reputation: 2099
You could just use NOW()
SELECT matchId FROM Matches where matchDate = DATE_FORMAT(NOW(), "%y-%m-%d %h:00:00");
Upvotes: 2
Reputation: 31417
You could use DATE_FORMAT
, with %Y-%m-%d
for date and %H
for hours.
SELECT DATE_FORMAT(NOW(), "Date : %Y-%m-%d Hour : %H")
It returns
Date : 2018-01-31 Hour : 15
Upvotes: 2