Reputation: 51
I have this SQL query, and I want to display only the years. How can I do it? I'm getting years, months, days, and hours. Thank you.
SELECT date_of_birth, AGE(now(), date_of_birth) AS age
FROM students
ORDER BY age DESC
Upvotes: 0
Views: 20
Reputation: 1269573
You can use extract()
:
select extract(year from AGE(now(), date_of_birth))
Upvotes: 1