whitz11 whitz11 - 1 month ago 12
SQL Question

picking out data from 2 months ago only

I'm currently using this which gives me all the data from the previous month. So if i run it today in November, i get all of Octobers data.

Now i need to tweak this so it only shows data in September, and when we're in December will only show October etc

[DateTimeOfCall] between DATEADD(month, datediff(month, 0, getdate())-1, 0) and DATEADD(month, datediff(month, 0, getdate())+0, 0)


Thank you

Answer

My guess would be

[DateTimeOfCall] between DATEADD(month, datediff(month, 0, getdate())-2, 0)    
                     and DATEADD(month, datediff(month, 0, getdate())-1, 0)