/****** Object:  UserDefinedFunction [dbo].[fnx_getFullYears]    Script Date: 18.10.2016 13:12:29 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fnx_getFullYears]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[fnx_getFullYears]
GO
--SET ANSI_NULLS ON
--GO
--SET QUOTED_IDENTIFIER ON
--GO
--CREATE FUNCTION [dbo].[fnx_getFullYears] 
--(
--    @dateX datetime,
--    @dateY datetime
--)  
--RETURNS int
--AS  
--BEGIN 
--    DECLARE @y int, @lastYearDate datetime
--    set @lastYearDate = Cast(DATEPART(YEAR, @dateY) as varchar(4)) + '1231'
--    SET @y =DATEDIFF(year,@dateX,@lastYearDate)
--    RETURN @y
--END
