I have 7 slightly different date functions that work out YTD bookings [Jan to Dec] based on created & arrival dates [please see below]. My question is this, how do I easily change these to accommodate for an April to March Financial Year instead of January to December?
1. --CREATED BY YEAR--LAST YEAR - UP TO TODAY'S DATE (BASED ON *CREATED DATE*)---
COUNT(CASE WHEN (CAST(MASTER_VIEW_TradingReports.CreatedDate AS DATE)>=CAST(DATEPART(yyyy,DATEADD(m,-12,GETDATE())) AS VARCHAR)+'-01-01') AND (CAST(MASTER_VIEW_TradingReports.CreatedDate AS DATE)<DATEADD(m,-12,GETDATE())) THEN MASTER_VIEW_TradingReports.HolidayCost END) AS [LastYearToDateBookingsCreated]
2. --CREATED BY YEAR--THIS YEAR - UP TO TODAY'S DATE (BASED ON *CREATED DATE*)---
COUNT(CASE WHEN MASTER_VIEW_TradingReports.CreatedYear=DATEPART(yyyy,GETDATE()) THEN MASTER_VIEW_TradingReports.HolidayCost END) AS [ThisYearToDateBookingsCreated]
3. --ARRIVALS BY YEAR--LAST YEAR - UP TO TODAY'S DATE (BASED ON *ARRIVAL DATE*, NOT CREATED DATE)---
ISNULL(COUNT(CASE WHEN (DATEPART(yyyy, MASTER_VIEW_TradingReports.ArrivalDate) = DATEPART(yyyy, DATEADD(m, - 12, GETDATE())) AND CAST(MASTER_VIEW_TradingReports.CreatedDate AS DATE) <= DATEADD(m, - 12, GETDATE())) THEN MASTER_VIEW_TradingReports.HolidayCost END), 0) AS [LastYearToDateBookings]
4. --ARRIVALS BY YEAR--THIS YEAR - UP TO TODAY'S DATE (arrivals this year onward, with any createdate up to today)---
ISNULL(COUNT(CASE WHEN (DATEPART(yyyy, MASTER_VIEW_TradingReports.ArrivalDate) = DATEPART(yyyy, GETDATE()) AND CAST(MASTER_VIEW_TradingReports.CreatedDate AS DATE) <= GETDATE()) THEN MASTER_VIEW_TradingReports.HolidayCost END), 0) AS [YearToDateBookings]
5. --ARRIVALS BY YEAR--NEXT YEAR - UP TO TODAY'S DATE (arrivals next year, with any createdate up to today)---
ISNULL(COUNT(CASE WHEN (DATEPART(yyyy, MASTER_VIEW_TradingReports.ArrivalDate) = DATEPART(yyyy, GETDATE()) + 1 AND CAST(MASTER_VIEW_TradingReports.CreatedDate AS DATE) <= GETDATE()) THEN MASTER_VIEW_TradingReports.HolidayCost END), 0) AS [NextYearToDateBookings]
6. --ARRIVALS ANYTIME THIS YEAR THAT WERE CREATED UP TO TODAY'S DATE LAST YEAR--
ISNULL(COUNT(CASE WHEN (DATEPART(yyyy, MASTER_VIEW_TradingReports.ArrivalDate) = DATEPART(yyyy, GETDATE()) AND (DATEPART(yyyy, MASTER_VIEW_TradingReports.CreatedDate) = DATEPART(yyyy, GETDATE())-1 AND CAST(MASTER_VIEW_TradingReports.CreatedDate AS DATE)<=CAST(DATEADD(d,-364,GETDATE()) AS DATE))) THEN MASTER_VIEW_TradingReports.HolidayCost END), 0) AS ThisYearToDateBookingsByArrivalsBookedLastYear
7. --ARRIVALS ANYTIME NEXT YEAR THAT WERE CREATED UP TO TODAY'S DATE THIS YEAR---
ISNULL(COUNT(CASE WHEN (DATEPART(yyyy, MASTER_VIEW_TradingReports.ArrivalDate) = DATEPART(yyyy, GETDATE())+1 AND (DATEPART(yyyy, MASTER_VIEW_TradingReports.CreatedDate) = DATEPART(yyyy, GETDATE()))) THEN MASTER_VIEW_TradingReports.HolidayCost END), 0) AS NextYearToDateBookingsByArrivalsBookedThisYear