Sunday, April 3, 2011

How do I get revolving last 12 months in T-SQL 2005?

At the moment I use DATEPART(yy, MY_DATE) = DATEPART(yy, GETDATE()) to get Year-To-Date details and have to convert it into the revolving last 12 months. How would I do that?

From stackoverflow
  • You can do date arithmetic with dateadd, e.g. where MY_DATE > dateadd (yy, -1, getdate())

    Garry Shutler : This is exactly what I was going to put.
    Greg : Thanx a million!

0 comments:

Post a Comment