CREATE FUNCTION [dbo].[fnGetFiscalYear] ( @sysDate DATETIME )
RETURNS VARCHAR(20)
AS
BEGIN
DECLARE @FiscalYear VARCHAR(20)
SELECT @FiscalYear = ( CASE WHEN ( MONTH(@sysDate) ) <= 3
THEN CONVERT(VARCHAR(4), YEAR(@sysDate) - 1)
+ '-'
+ CONVERT(VARCHAR(4), YEAR(@sysDate))
ELSE CONVERT(VARCHAR(4), YEAR(@sysDate))
+ '-'
+ CONVERT(VARCHAR(4), YEAR(@sysDate) + 1)
END )
RETURN @FiscalYear
END
SELECT [dbo].[fnGetFiscalYear] ( GetDate() )