0

How to select records from last 24 hours using SQL?

In MySQL

SELECT  *
FROM    mytable
WHERE   record_date >= NOW() - INTERVAL 1 DAY

In SQL Server

SELECT  *
FROM    mytable
WHERE   record_date >= DATEADD(day, -1, GETDATE())

In Oracle

SELECT  *
FROM    mytable
WHERE   record_date >= SYSDATE - 1

In PostgreSQL

SELECT  *
FROM    mytable
WHERE   record_date >= NOW() - '1 day'::INTERVAL

In Redshift

SELECT  *
FROM    mytable
WHERE   record_date >= GETDATE() - '1 day'::INTERVAL

In SQLite

SELECT  *
FROM    mytable
WHERE   record_date >= datetime('now','-1 day')

In MS Access

SELECT  *
FROM    mytable
WHERE   record_date >= (Now - 1)
add comment
Suggest a different solution or add another example