Reputation: 41
I have the following MySQL query:
SELECT * FROM m3
WHERE datetime >= DATE_SUB(NOW(), INTERVAL 8 HOUR) AND mod(minute(time),1) = 0
ORDER BY id ASC ";
The output for this query is for example now: 18:30:34
Every minute there will be a new datetime, and I will select only the full (half) hours. So 18:30, 19:00, 19:30, 20:00 etc.
Now I want only select the hours and minutes without the seconds included.
So for example: 18:30.
How can I manage it to have it in this query?
Upvotes: 1
Views: 2183
Reputation: 692
Try SELECT DATE_FORMAT(datetime, '%H:%i') ...
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
Upvotes: 2