Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Dealing with dates
Working with time
Date and time data types in PostgreSQL
Extracting dates and times
Timezone conversion
Format date and time
Current date and time data


Awesome! Sometimes we want to know, for example, how old a person was on the day of their death. We will use another syntax of the AGE() function:

AGE(end_timestamp, start_timestamp)

Note that the start_timestamp is counter-intuitively the second argument.

The query below returns an interval of time between withdrawn timestamp and launched timestamp:

SELECT AGE(withdrawn_timestamp, launched_timestamp)
FROM aircraft
WHERE id = 9;
1 years 7 mons 18 days 17 hours 26 mins 0.00 secs

The returned result is the actual difference between the time this aircraft was launched and the time it was withdrawn. The result of the AGE() is the interval.


For each aircraft, select its ID and show the difference in years, months, and days between its registration and production date (as the difference column).

Stuck? Here's a hint!

Use this expression:

AGE(registration_timestamp, produced_date) AS difference