For some reason justify_interval(now() - \'2013-02-14\'::timestamptz)
produces weird results:
postgres=# select justify_interval(concat(365*4 +1
It seems that you are looking for something, which PostgreSQL calls a "symbolic" result that uses years and months, rather than just days, which is what the age(timestamp, timestamp)
(and age(timestamp)
) function(s) returns.
select age(now(), '2013-02-14'); -- 4 years 16:41:02.571547
select age(timestamp '2013-02-14'); -- 4 years
The -
operator always returns the difference in days (at most). The justify_*()
functions (and the *
, /
, <
, >
operators) always "cut" values to an average (i.e. 1 day
is 24 hours
and 1 month
is 30 days
) despite the fact that 1 day actually can contain 23-25 hours (just think of daylight saving time zones) and 1 month can contain 28-31 days (so the result depends on the actual start and end points of the range, which creates the interval).