ALTER FUNCTION [dbo].[fn_BugunYasHesapla](@DogumTarihi datetime,@Bugun datetime)
RETURNS INT
AS
BEGIN
Declare @Yas int
set @Yas=(SELECT
DATEDIFF(YEAR,@DogumTarihi,@Bugun)
-CASE
WHEN DATEADD(YY,DATEDIFF(YEAR,@DogumTarihi,@Bugun),@DogumTarihi)>@Bugun
THEN 1
ELSE 0
END AS DogumTarihi)
RETURN @Yas
END
SELECT dbo.fn_BugunYasHesapla('27.01.1979',getdate()) as Yas