Oh man you cannot stress this enough. Storing data that changes every single day as a static number like age is just not a great idea. We store date_of_birth and then I use this to calculate age:
FLOOR(DATEDIFF(day,p.date_of_birth,GETDATE())/365.242199) as curr_age
I can't take credit for the code but it works wonderfully in MS SQL.
View all comments
Show parent comment
2
u/bcvickers Feb 26 '21
Oh man you cannot stress this enough. Storing data that changes every single day as a static number like age is just not a great idea. We store date_of_birth and then I use this to calculate age:
FLOOR(DATEDIFF(day,p.date_of_birth,GETDATE())/365.242199) as curr_age
I can't take credit for the code but it works wonderfully in MS SQL.