From MySQL's date and time functions, we can combine TIMESTAMPDIFF
, NOW
, and FROM_UNIXTIME
.
Supposing that dob
is a Unix timestamp representing date of birth:
TIMESTAMPDIFF(YEAR, FROM_UNIXTIME(dob), NOW())
From there, it's simple enough to add a WHERE
clause based on the column value.
Live demo on SQLFiddle.