USE [EnVisage]
GO

IF EXISTS(SELECT * FROM sys.objects WHERE Name = N'GetFCMaxDate')
BEGIN
	DROP FUNCTION GetFCMaxDate
END
GO

CREATE FUNCTION [dbo].[GetFCMaxDate] ()
RETURNS date
AS
BEGIN
	DECLARE @ret date

	select @ret = MAX(EndDate) from FiscalCalendar
		where ([Type] = 0) and (NonWorking = 0)
		
	RETURN @ret
END
GO
