I have an age on the format 57 years 5 months 7 days
, and I want to deduct the date of birth from it in postgresql on a format like yyyy-mm-dd
, how do I do that?
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
2
Answers
We can get the past date using multiple
intervals
. I added a couple examples to the data to check that it’s working.Fiddle
Here’s a way with
concat_ws
Here’s a way with
make_interval
Here’s a way with
format
Fiddle