I am looking for a way to implement the SQLServer-function datediff in PostgreSQL. That is,
This function returns the count (as a signed integer valu
Here is a complete example with output. psql (10.1, server 9.5.10).
You get 58, not some value less than 30.
Remove age() function, solved the problem that previous post mentioned.
drop table t;
create table t(
d1 date
);
insert into t values(current_date - interval '58 day');
select d1
, current_timestamp - d1::timestamp date_diff
, date_part('day', current_timestamp - d1::timestamp)
from t;
d1 | date_diff | date_part
------------+-------------------------+-----------
2018-05-21 | 58 days 21:41:07.992731 | 58