Postgresql timestamp difference greater than 1 hour

Viewed 1325

Hi I have a entrytime and exittime timestamp in my database, how can I query it to display only ones where the person exited more than an hour later;

Select * from store where EXTRACT(EPOCH FROM (exittime - entrytime))/3600 >60

That's what I have so far but it won't work, any help would be appreciated.

1 Answers

Just subtract the values and compare it with an interval

Select * 
from store 
where exittime - entrytime > interval '1 hour';

This assumes that both columns are defined as timestamptz or timestamp

Related