I have a query that I thought I had cracked to return all records where the start date is between 18 and 9 months ago but I want all of the records for the month 18 months ago from the 1st of the month and all of the records for the month 9 months ago to the end of the month as well as the records in between. At the moment my WHERE clause contains:
WHERE startdate BETWEEN
DATEADD(DAY, - (DAY(DATEADD(MONTH, 1, GETDATE())) - 18), DATEADD(MONTH, - 18, GETDATE()))
AND DATEADD(DAY, - (DAY(DATEADD(MONTH, 1, GETDATE())) - 9), DATEADD(MONTH, - 9, GETDATE())
But it is pulling all records where start date is between 18 and 9 months ago to the exact date today and is not going back to the start of the month or completing the end month. Please could you advise where I have gone wrong. I am sure it is something really simple but I have gone bracket blind now I think.