Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CREATE function [dbo].[fn_GetAge]
(@in_DOB AS datetime,@now as datetime)
returns int
as
begin
DECLARE @age int
IF cast(datepart(m,@now) as int) > cast(datepart(m,@in_DOB) as int)
SET @age = cast(datediff(yyyy,@in_DOB,@now) as int)
else
IF cast(datepart(m,@now) as int) = cast(datepart(m,@in_DOB) as int)
IF datepart(d,@now) >= datepart(d,@in_DOB)
SET @age = cast(datediff(yyyy,@in_DOB,@now) as int)
ELSE
SET @age = cast(datediff(yyyy,@in_DOB,@now) as int) -1
ELSE
SET @age = cast(datediff(yyyy,@in_DOB,@now) as int) - 1
RETURN @age
end
([dbo].[fn_GetAge]([DOB], getdate()))