I’m working my way through a SQL Challenge Project in the Data Science Career Path and seem to be stuck on a final extra problem
Basically we have a column that is birthdates and they want us to add a column that calculates a persons age based on this.
After some Googling I learned about DATEDIFF but I can’t seem to use it right. My code is below as follows
#Adds the age column to the table
ALTER TABLE users
ADD COLUMN age int NULL;
#Attempting to update the table by setting the age column to the #DATEDIFF function
SET age = DATEDIFF(year, birthday, GETDATE());
#Trying to view the table to see if it worked
I’ve found the error is in the Updating part but i can’t seem to find the problem.
Any help or guidance would be greatly appreciated!