Question: how to calculate date difference in years months and days in sql?
Answer: Declare @dateofbirth datetime. Declare @currentdatetime datetime. Declare @years varchar(4) set @dateofbirth = '1986-03-15' --Birthdate. set @currentdatetime = getdate() --Current Datetime. select @years = datediff(year,@dateofbirth,@currentdatetime) select @years + ' years,' as years.