
CREATE FUNCTION [dbo].[GetFiscalMonth] ( @datetime DATETIME )
RETURNS CHAR(2)
AS
BEGIN
	DECLARE @retval INT
			,@year INT
			,@month INT

	SELECT	@year = YEAR(@datetime)
			,@month = MONTH(@datetime)

	IF(@month < 10)
	BEGIN
		SET @retval = @month+3
	END
	ELSE
	BEGIN 
		SET @retval = @month-9
	END    
	
	RETURN REPLACE(STR(@retval, 2), SPACE(1), '0')
END

