简体   繁体   中英

PostgreSQL: SELECT WHERE less than 15 minutes old

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
);
SELECT created_at FROM events WHERE created_at > NOW() - INTERVAL '15 minutes';
SELECT * FROM events WHERE age(now(), created_at) < '15 minutes';

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM