SQL Server: Get data for only the past year

后端 未结 12 864
不思量自难忘°
不思量自难忘° 2020-12-12 17:09

I am writing a query in which I have to get the data for only the last year. What is the best way to do this?

SELECT ... FROM ... WHERE date > \'8/27/2007         


        
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 17:25

    The following adds -1 years to the current date:

    SELECT ... From ... WHERE date > DATEADD(year,-1,GETDATE())
    

提交回复
热议问题