I need to create a report that returns a range of data, based on an open date and any records opened within a month for each previous quarter.
So if I was to run the report at the start of August - it would show records which have an open date within May, Feb, November, August with no limit on the year. The open date month will be defined by the month where the report is run.
I have this very basic code
SELECT RecordMonth, RecordYear, caseRef, caseDescription,
caseOpenDate, caseClosedDate, PersonName, PersonSurname
FROM dbo.casereview
WHERE month(caseopendate) = 03
OR month(casecopendate) = 06
OR month(caseopendate) = 09
OR month(caseopendate) = 12
Issue is, I need this to run dynamically, so whichever month it is run, it can show cases where the open date falls within the previous quarters/months.