Go back 6 months in sql server
Posted on 2011-09-20
I want to be able to go back exactly 6 months from my current month in my orderdate field of myTableA. I've tried using
DATEADD(month, -6, GetDate())
But it'll pull records starting from let's say 03/20/2011 till today. But I want it to include ALL days in March so orderdates starting 03/01/2011 until today. I want to get records from the entire month, basically ignore the day and just look at the month (Sept, Aug, July, June, May, April and March). And if the current month is February 2012 then (Feb 2012, Jan 2012, Dec 2011, Nov, etc)
Any idea how I can do this?