SQL Server:只获取过去一年的数据 [英] SQL Server: Get data for only the past year
本文介绍了SQL Server:只获取过去一年的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在写一个查询,其中我只得到去年的数据。这是最好的方法是什么?
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:00:00 AM'
推荐答案
以下为当前日期添加-1年:
The following adds -1 years to the current date:
SELECT ... From ... WHERE date > DATEADD(year,-1,GETDATE())
这篇关于SQL Server:只获取过去一年的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文