Skip to content
Advertisement

Finding records older than a minute

I have a users table which consists of

some columns like name,age,created_at

created_at contains time in unix timestamps format (epoch).

I basically want to create a query to show all queries that are older than 1 minute.

I tried the following SELECT * FROM users WHERE created_at > NOW() - INTERVAL '1 minutes';

But i got the following error :

operator does not exist: double precesion > timestamp with time zone

Advertisement

Answer

Presumably, created_at is actually a Unix timestamp. That means it is measured in seconds, so you can do:

where created_at < extract(epoch from now() - interval '1 minute')
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement