mysql query to count the age from the dob in m/d/y format withim mysql query -
i making query age of user stored in d/m/y
in database . have tired make following query
select *,timestampdiff(year, dob, now()) age_new users_profile
but not seems work , return value null
. dob eg 12/5/1990
wanted calculate age within results . make new column , display count result inside new_age
as dob
field not in date
or datetime
format. need convert it.
here query worked fine me.
select year(from_days(datediff(now(), str_to_date('12/5/1990', '%d/%m/%y')))) age_new
or query be:
select year(from_days(datediff(now(), str_to_date(dob, '%d/%m/%y')))) age_new users_profile
Comments
Post a Comment