Isn't this what EXTRACT does? (Note the first paragraph that says it works on "interval" types)<p><a href="https://www.postgresql.org/docs/9.3/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT" rel="nofollow">https://www.postgresql.org/docs/9.3/functions-datetime.html#...</a><p>Just did a search and got it from here, which shows it being used on the difference between two dates: <a href="https://stackoverflow.com/questions/24929735/how-to-calculate-date-difference-in-postgresql" rel="nofollow">https://stackoverflow.com/questions/24929735/how-to-calculat...</a>
> DATEDIFF('year', '12-31-2020', '01-01-2021') returns 1 because even though the two dates are a day apart, they've crossed the year boundary.<p>What is the use of such a function? If I saw this answer I would assume a bug somewhere (until reading the documentation).
This seems like a big yet simple feature that Postgresql is missing. I've used this many times in SQL server.<p>I'm surprised there is not native function. Does anyone know why?