larrydavid
Programmer
Hello,
I am currently using this where clause to pull records for 18-months from the current date:
Now I am trying to apply the same logic to filter records for
the latest completed month (e.g., If August 15, 2011, then YTD – Current = Jan – Jul 2011).
And through latest completed month for the previous year (e.g., If August 15, 2011, then YTD – Previous = Jan – Jul 2010).
I've been trying to apply what I have for the 18-month filter but can't quite get it. I've tried searching for this and have been trying to work with something like this:
Any help in nailing this down for the Current and Previous YTD would be greatly appreciated as always.
Thanks,
Larry
I am currently using this where clause to pull records for 18-months from the current date:
Code:
convert(datetime, paiddate, 102) > dateadd(month, -18, convert(datetime, getDate(),102))
Now I am trying to apply the same logic to filter records for
the latest completed month (e.g., If August 15, 2011, then YTD – Current = Jan – Jul 2011).
And through latest completed month for the previous year (e.g., If August 15, 2011, then YTD – Previous = Jan – Jul 2010).
I've been trying to apply what I have for the 18-month filter but can't quite get it. I've tried searching for this and have been trying to work with something like this:
Code:
SELECT * FROM Test_Table
WHERE DateColumn > DATEADD(year,-1,getdate())
Any help in nailing this down for the Current and Previous YTD would be greatly appreciated as always.
Thanks,
Larry