calculate age in sql postgresql

Solutions on MaxInterview for calculate age in sql postgresql by the best coders in the world

showing results for - "calculate age in sql postgresql"
Isabelle
25 Jun 2017
1#THIS WORKS FOR POSTGRES and MYSQL
2# You can use the AGE function. The AGE function requires two arguementS.
3# AGE(late date, early date). The NOW() function returns the current timestamp.
4
5AGE(NOW(), date_of_birth) AS age
6
7#Since NOW() is a timestamp, the result will be like this:
8# 45 years 2 months 15 days 21:43:05.378372
9#You can then use this to extract the age.
10
11LEFT(age, STRPOS(age,' '))