20 lines
554 B
Transact-SQL
20 lines
554 B
Transact-SQL
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date, ,>
|
|
-- Description: <Description, ,>
|
|
-- =============================================
|
|
CREATE FUNCTION [dbo].[Eta]
|
|
(
|
|
-- Add the parameters for the function here
|
|
@dataNascita DATETIME
|
|
)
|
|
RETURNS INT
|
|
AS
|
|
BEGIN
|
|
-- Declare the return variable here
|
|
DECLARE @eta INT
|
|
-- Add the T-SQL statements to compute the return value here
|
|
SET @eta = FLOOR(DATEDIFF(day, @dataNascita, GETDATE()) / 365.25)
|
|
-- Return the result of the function
|
|
RETURN @eta
|
|
END |