Find records with a date field in the last 24 hours [duplicate] Find records with a date field in the last 24 hours [duplicate] sql sql

Find records with a date field in the last 24 hours [duplicate]


You simply select dates that are higher than the current time minus 1 day.

SELECT * FROM news WHERE date >= now() - INTERVAL 1 DAY;


SELECT * FROM news WHERE date > DATE_SUB(NOW(), INTERVAL 24 HOUR)


To get records from the last 24 hours:

SELECT * from [table_name] WHERE date > (NOW() - INTERVAL 24 HOUR)