I have a table with date of birth and I want to use a CreateFunction to calculate their age.
So I was thinking along the lines of extracting year from current date - Year for their date of birth (using YEAR() function as shown below)
The function below doesn't seem to work so any help would be appreciated!
DELIMITER $$
CREATE FUNCTION customer_age(DateOfBirth DATE)
RETURNS DATE
BEGIN
DECLARE age DATE
SET age = YEAR(curdate())- YEAR(DateOfBirth);
RETURN (age);
END $$
DELIMITER;