I have an age calculation formula that is returning a negative month value. This does not happen to all values, can someone shed any light as to what the cause is and possibly provide a fix please?
Declare @dateofbirth datetime
Declare @currentdatetime datetime
Declare @years varchar(40)
Declare @months varchar(30)
set @dateofbirth='1982-12-16'--birthdate
select concat(datediff(year,@dateofbirth,getdate()),'\', datediff(month,@dateofbirth,getdate())-(datediff(year,@dateofbirth,getdate())*12)) [Year\Month]
RESULT : Year\Month 37-3
Thanks,