Date Difference in MySQL to calculate age
date, datediff, mysql, sql
Solution
You mean like this?
SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), dob)), "%Y")+0 AS age from sometable
(Source)
Problem
I have a problem regarding the `datediff` MYSQL function, I can use it and it is simple. But I don't understand how to use it to collect differences within the table field. E.g. I have a column `dob` and I want to write a query that will do something like ``` select dateDiff(current_timeStamp,dob) from sometable 'here dob is the table column ``` I mean I want the difference from the current date time to the table field `dob`, each query result is the difference, the age of the user.