Reputation: 253
My date of birth format is : 2017-Feb-15
when I am using the following query, it's not working
select (year(current_date)-year(dob)) as age from user
or how to current 2017-Feb-15 into 2017-02-15 format
Upvotes: 1
Views: 5534
Reputation: 585
You can use TIMESTAMPDIFF.
select TIMESTAMPDIFF(YEAR, str_to_date(dob, '%Y-%M-%d'), current_date) AS age
from user;
Upvotes: 1