Get the exact person Age

CREATE FUNCTION [dbo].[GetAge] (@BirthDate DateTime)
RETURNS int
AS
BEGIN
   DECLARE @AgeValue int,@CurrentDate datetime
   SET @CurrentDate=GETDATE()
   IF ISDATE(@BirthDate)=1
      BEGIN   
        IF (MONTH(@CurrentDate)<MONTH(@BirthDate))
           BEGIN 
           SET @AgeValue = (YEAR(@CurrentDate)-YEAR(@BirthDate))-1
           END
        ELSE
           BEGIN 
           SET @AgeValue = (YEAR(@CurrentDate)-YEAR(@BirthDate))
           END 
      END
   ELSE
      BEGIN
	SET @AgeValue = 0
      END
   RETURN(@AgeValue)
END
HOW TO USE IT
SELECT dbo.GetAge('12/03/1950')

Add Feedback