Getting the age of someone

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Getting the age of someone

Post by emmbec »

Hi I know this may seem like a very basic question but I just don't seem to figure it out. I have a record in my Database which is the date of birth, and I want to know how old that person is. How could I do it?? My column in my DB is of type DATE. Thanks
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Code: Select all

SELECT DATEDIFF(birthdayColumn, CURDATE());
Will return the number of days since the date. Though, floor($daysPastBirthday / 365) won't account for leap years.
Post Reply