纸上得来终觉浅,绝知此事要躬行。

 

SqlServer中取前三个月的记录(实时的)

 

 

select operDate from RechargeRecord where datediff(month,'数据库时间字段',getdate())=3

 

 

这一句的意思是查询数据库中距现在三个月以内的数据。getdate()取得当前日期,SQL Server函数和now()一样。

具体查看:

http://www.w3school.com.cn/sql/func_datediff.asp

posted on 2010-12-17 15:43  JRoger  阅读(5365)  评论(2编辑  收藏  举报

导航