I'm trying to write a query to return all transactions with a transaction date from within the last 12 whole months prior to today's date.
So for example, if today's date is 10th March 2017, the query should return all transactions between 01 March 2016 and 28 Feb 2017.
I've got this far:
WHERE CONVERT(date, t1.transactiondate) BETWEEN DATEADD(month,-13,GETDATE()) AND DATEADD(month,-1,GETDATE())
...but this gives me all transactions between 11th Feb 2016 and 10th Feb 2017 - close, but not correct.
I'm new to SQL so all help welcome - please be gentle 🙂