You may need to consider to handle the leap year as well.
Select a.CustID, a.OrderDate, Floor(DATEDIFF(DAY,b.Birthdate, a.OrderDate) / 365.2425) ageasoforderdate from OrderHistory a inner join Customer b on a.CustID = b.CustId
It does appear there does need to be considerations for leap year. Works fine unless birthday is in februarySo, you need to tell us what if customer's DOB is on 29 Feb, how you wish to handle this?
Open in new window