如何从表中获取最近3个月的数据 [英] how to get last 3 months data from a table

查看:97
本文介绍了如何从表中获取最近3个月的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要从数据库中获取最近3个月的记录。



例如,3月是当前月份(03 / 2012),我需要3月(03),2月(02)和1月(01)月的数据。



请帮助

Hi,
I need to get last 3 months records from database.

For example, March is the current month (03/2012), i need data from March(03), February(02) and January(01) months.

please help

推荐答案

Select * from TableName
where dateColumn between dateadd(mm,-3,getdate()) and getdate()  


这篇关于如何从表中获取最近3个月的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆