#THIS IS FOR POSTGRES
# You can use the AGE function. The AGE function requires two arguementS.
# AGE(late date, early date). The NOW() function returns the current timestamp.
AGE(NOW(), date_of_birth) AS age
#Since NOW() is a timestamp, the result will be like this:
# 45 years 2 months 15 days 21:43:05.378372
#You can then use this to extract the age.
LEFT(age, STRPOS(age,' '))
DATEDIFF (datepart, start, end)
Select *, DATEDIFF(year, DOB,GETDATE()) as COLUMN_NAME from TABLE_NAME
GETDATE = CURRENT DATE
DOB = PATIENT'S DATA OF BIRTH
YEAR = FORMAT THAT WILL RETURN THE PATIENT AGE FOR EXAMPLE: 21
(IF YOU PUT MONTH INSTEAD OF YEAR , IT WILL GIVE YOU THE AGE IN MONTHS, LIKEWISE FOR DAY)
FOR EXAMPLE: YEAR = 21, MONTH = 252, DAY = 7665