Find out age using SQL

Hi I’m using sql to find out how old someone is. Im doing this using columns Name, Date of birth and todays date.

I used this query below and it works.

SELECT DOB, CURDATE() AS TODAY ,TIMESTAMPDIFF(YEAR,DOB,CURDATE()) AS AGE FROM data

I was just wondering if this is the best way to find a person’s age or is there a better way of writing this or more effiecient way.

Any help would be much appreciated

you’re good

(i wasn’t sure so i tested it, and i could detect no rounding issues with dates such as birthday being tomorrow)

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.