Reputation: 126327
From the events
table below, how do I select events
created less than 15 minutes ago?
CREATE TABLE events (
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Upvotes: 43
Views: 37236
Reputation: 127086
SELECT created_at FROM events WHERE created_at > NOW() - INTERVAL '15 minutes';
Upvotes: 91
Reputation: 126327
SELECT * FROM events WHERE age(now(), created_at) < '15 minutes';
Upvotes: 15