How do I resume the last 12 months in T-SQL 2005?

I am currently using DATEPART (yy, MY_DATE) = DATEPART (yy, GETDATE ()) to retrieve data one year before the date and must convert it to the number of revolutions of the last 12 months. How can I do it?

+3
source share
1 answer

You can do date arithmetic with dateadd, for example. where MY_DATE > dateadd (yy, -1, getdate())

+11
source

Source: https://habr.com/ru/post/1711326/


All Articles