Determining The Age Of Things
In PostgreSQL, we can determine the age of something (or someone) by passing a timestamp to the age
function.
For instance, if we want to know how long it has been since y2k, we can run the following query:
Additionally, if we want to know the amount of time between two dates, we can pass two timestamps to the age
function.
For example, we can find out how old Prince lived to be by passing in the date of death and then date of birth:
h/t Josh Davey
Last updated