I need to calculate the age of a \"customer\" from their date of birth.
I have tried to use the following:
DATEDIFF(year, customer.dob, \"2010
Assumed the given date is greater than the current date,
1.Find the total no of days b/w the current date and the given date.
-> DATEDIFF(NOW(),'1988-05-01')
2.Find the no of years from the calculated no of days.
-> DATEDIFF(NOW(),'1988-05-01')/365.25
3.The age should be the completed no of years by a person. To get it, we can use 'floor' to the calculated no of years.
-> FLOOR(DATEDIFF(NOW(),'1988-05-01')/365.25)
Example: SELECT FLOOR(DATEDIFF(NOW(),'1988-05-01')/365.25) AS age;