Instruction
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;
| age |
|---|
| 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.
Exercise
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



