PostgreSQL 18 reference · Date and Time Functions

PostgreSQL AGE() Function

Subtract dates and return a 'symbolic' interval in years, months and days. With one argument it counts from today.

PostgreSQL 18

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

age(timestamp, timestamp)  |  age(timestamp)

Parameters

ParameterDescription
timestamp The later and the earlier value.

Return value

interval.

Examples

Years, months and days
SELECT age(DATE '2026-10-22', DATE '2018-03-01') AS tenure;

Output

         tenure
------------------------
 8 years 7 mons 21 days
(1 row)

Run this on your computer — see “Get Started” for setup.

Whole years
SELECT name, EXTRACT(year FROM age(DATE '2026-10-22', hire_date)) AS full_years
FROM employees
LIMIT 3;

Output

    name     | full_years
-------------+------------
 Sofia Reyes |          8
 Omar Haddad |          8
 Mei Chen    |          7
(3 rows)

Run this on your computer — see “Get Started” for setup.

In other languages

Was this page helpful?