DATEDIFF equivalent

Hello!

I’m looking for the PostGres equivalent of the following t-SQL statement:
DELETE FROM ERRORLOG WHERE DATEDIFF(hh, ERR_DATETIME, GETDATE()) >= 168;

The field “ERR_DATETIME” is of type “datetime” in SQL Server and of type “timestamp without time zone” in PostGres.
Thanks for any advice in advance!

You can simply subtract the values, for instance:

test=*# select current_date - '2014-01-01'::date;
 ?column?
----------
      196
(1 row)

Can we switch to german, please?

Aber mein Datum steht doch in der ERR_DATETIME Spalte und
select current_date - “ERR_DATETIME”::date;
geht leider nicht :frowning:



test=*# create table loonis(err_date date);
CREATE TABLE
test=*# insert into loonis values ('2014-01-01');
INSERT 0 1
test=*# select current_date - err_date from loonis ;
 ?column?
----------
      196
(1 row)

test=*# rollback;
ROLLBACK