Tuesday, 6 July 2010

Financial Quarters in SSRS

Use case to determine Qtr based on month datepart

This example uses Invoice created on date and has a Fiscal year of 1st Oct

SELECT CASE WHEN (DATEPART(mm, FilteredInvoice.createdon) > 9)
THEN 1 WHEN (DATEPART(mm, FilteredInvoice.createdon) < 4) THEN 2 WHEN (DATEPART(mm, FilteredInvoice.createdon) < 7)
THEN 3 WHEN (DATEPART(mm, FilteredInvoice.createdon) < 10) THEN 4 END AS Qtr
FROM FilteredInvoice