hello,
i find this code it works fine but the problem is as SP it works but i want it to convert it to function so it is not working
Declare @dateofbirthdatetime
Declare @currentdatetimedatetime
Declare @yearsvarchar(40)
Declare @monthsvarchar(30)
Declare @daysvarchar(30)
set @dateofbirth='1986-03-15'--birthdate
set @currentdatetime =getdate()--current datetime
select @years=datediff(year,@dateofbirth,@currentdatetime)-- To find Years
select @months=datediff(month,@dateofbirth,@currentdatetime)-(datediff(year,@dateofbirth,@currentdatetime)*12)
-- To Find Months
select @days=datepart(d,@currentdatetime)-datepart(d,@dateofbirth)-- To Find Days
select @years +' years, ' +@months +' months, '+@days +' days' asYearMonthDay