AGE
AGE is an SQL function primarily used in PostgreSQL. It calculates the difference between the current date (today's date) and the input date returning the result in the form of years, months, and days. The AGE function does not exist in all other DBMS such as MySQL or SQL Server.
Example
Output
Explanation
In the provided example, the AGE
function in PostgreSQL is used to calculate the age between the current date and the specified date, ‘2000-01-01’. The result ‘21 years 10 mons’ shows the time difference in years and months.