How would you calculate the fiscal year from a date field in a view in SQL Server?
I've extended the answer posted by ChrisF and Conficker.
DECLARE @FFYStartMonth INT = 10 --The first month of the FFY
DECLARE @EntryDate DATETIME = '4/1/2015' --The date of the data
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = DATEADD(dd, 0,
DATEDIFF(dd, 0,
DATEADD(mm, - (((12 + DATEPART(m, @EntryDate)) - @FFYStartMonth)%12), @EntryDate) -
datePart(d,DATEADD(mm, - (((12 + DATEPART(m, @EntryDate)) - @FFYStartMonth )%12),
@EntryDate )) + 1 ))
SET @EndDate = DATEADD(SS, -1, DATEADD(mm, 12, @StartDate))
SELECT @StartDate, @EndDate