This procedure gets a parameter and returns three parameters. Those parameters are year, month and day.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Create Procedure SP_Age_Calculate_Detail(@birthdate datetime,@year int output,@month int output,@day int output) as Begin Set @year = DATEDIFF(yy,@birthdate,getdate()) Set @birthdate = DATEADD(yy,@year,@birthdate) Set @month = DATEDIFF(MM,@birthdate,getdate()) Set @birthdate = DATEADD(MM,@month,@birthdate) Set @day = DATEDIFF(DD,@birthdate,getdate()) End -- First Execute the code above, if you get successful message, then you can learn the age of you entered birthdate Declare @year int,@month int,@day int Execute SP_Age_Calculate_Detail '10.04.1984',@year output,@month output,@day output Select @year [Year],@month [Month],@day [Day] |
Result of The Query
