Hi I am trying to select row's where the datefiled eg 11-11-2011 12:00
is equal to the current hour.
Sorry, to add it should match the whole date but round to the hour.
Here's what I have so far :
SELECT * FROM emails WHERE SUBSTRING(datetosend,0,12) = SUBSTRING(NOW(),0,12)
SELECT *
FROM emails
WHERE DATE_FORMAT(datetosend, '%Y-%m-%d %H') = DATE_FORMAT(NOW(), '%Y-%m-%d %H');
This sql doesn't care which date format your column is using.
Try this:-
SELECT *
FROM emails
WHERE HOUR(datetosend) = HOUR(NOW());
尝试这个:
SELECT * FROM x where SUBSTRING(d,0,12)= SUBSTRING(date_format(NOW(), '%d-%m-%Y %I' ),0,12 )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.