Sach jot
Sach jot

Reputation: 160

How to get the records from the past 1 hour in psql

SELECT * FROM auto_sync WHERE time > UNIX_TIMESTAMP(NOW() - INTERVAL 1 HOUR);

I am trying to fetch data which get added in the past 1 hour from my query but it's throwing me an error on Internal 1. Thank you

Upvotes: 4

Views: 5017

Answers (2)

user9370143
user9370143

Reputation:

Try this.

SELECT * FROM table_name
WHERE timestamp >= NOW() - INTERVAL 1 HOUR
ORDER BY timestamp DESC

Upvotes: 3

CantFetchEJB
CantFetchEJB

Reputation: 21

SELECT * FROM table_name WHERE timestamp >= NOW() - INTERVAL 1 HOUR ORDER BY timestamp DESC

try this maybe? not sure if timestamp or time, try with both

Upvotes: 1

Related Questions