Thanks All!
I ended up using a combination of all your suggestions to Declare Last, This and Next financial years (FY). Ours is around 1st November but you could use any date!
You just need to replace @today with getdate() ad then it runs forever! You can test it by adding a manual date as int he example below...
The one ares I am stuck with is that it looks like the last date is eg '2014.10.31 00:00:00' instead of '2014.10.31 23:59:59'
You can select it out using DATEADD (S, 86399, @lastFYend) but I need to ensure the @fixedend includes Hours minutes and seconds.
Any suggestions?
-- when are we now?
Declare @today smalldatetime; set @today = '2014.10.14' -- for testing, normally set to getdate()
Declare @1NOVthisyear AS smalldatetime; Set @1NOVthisyear = DATEADD(year,DATEDIFF(year,'20010101',@today),'20011101')
Declare @30Octlastyear AS smalldatetime; Set @30Octlastyear = DATEADD(year,DATEDIFF(year,'20010101',@today),'20001031')
Declare @addyears INT; Set @addyears = (Select Case when @today >= @1NOVthisyear then 1 when @today < @1NOVthisyear then 0 END )
-- FY start / End dates
DECLARE @fixedstart VARCHAR(4) = '1101'
DECLARE @fixedend VARCHAR(4) = '1031'
DECLARE @nextnextYear VARCHAR(4) = CONVERT(VARCHAR(4), Year(@today) + @addYears +1)
DECLARE @nextYear VARCHAR(4) = CONVERT(VARCHAR(4), Year(@today) + @addYears)
DECLARE @thisYear VARCHAR(4) = CONVERT(VARCHAR(4), Year(@today) + (@addYears -1))
DECLARE @lastYear VARCHAR(4) = CONVERT(VARCHAR(4), Year(@today) + (@addYears -2))
--starts
DECLARE @nextFYstart DATEtime = CONVERT(smalldatetime, @nextYear + @fixedstart)
DECLARE @thisFYstart DATEtime = CONVERT(smalldatetime, @thisYear + @fixedstart)
DECLARE @lastFYstart DATEtime = CONVERT(smalldatetime, @lastYear + @fixedstart)
--ends
DECLARE @nextFYend DATEtime = CONVERT(smalldatetime, @nextnextYear + @fixedend)
DECLARE @thisFYend DATEtime = CONVERT(smalldatetime, @nextYear + @fixedend)
DECLARE @lastFYend DATEtime = CONVERT(smalldatetime, @thisYear + @fixedend)
Select
---- testing
--@lastFYstart As 'Last FY start',
--DATEADD (S, 86399, @lastFYend) AS 'Last FY End',
--@thisFYstart As 'This FY start',
--DATEADD (S, 86399, @thisFYend) AS 'This FY End',
--@nextFYstart As 'Next FY start',
--DATEADD (S, 86399, @nextFYend) AS 'Next FY End'