I have this basic PostgreSQL query:
SELECT AGE('2021-01-21', '1942-11-20');
Which returns an interval in days:
output: 28531 days, 0:00:00
I am using PostgreSQL version 14, according to the docs, AGE() should return a symbolic result in years, months and days instead of just days.
Does anyone know why this interval is returned in days instead of in years, months, days?
2
Answers
What you’re saying is correct it should display the years, months and days.
Maybe you could use this statement where you specify the format you’d like to recieve to get the desired ouput:
Function
age
returns typeinterval
which you can format as you need usingto_char
. Here is an illustration. I would strongly suggest that you control the presentation explicitly rather than rely on defaults.Results: