读书人

用mysql查询当前时间至6个月前的数据如

发布时间: 2012-06-01 16:46:36 作者: rapoo

用mysql查询当前时间至6个月前的数据怎么查询?
用mysql查询当前时间至6个月前的数据怎么查询?

sqlserver可以这样查 select * from table between getdate()-180 and getdate()

请问mysql查询6个月之间的数据!!

[解决办法]


select * from table where yourTimeColumn >CURDATE() -180;.
==== 思想重于技巧 ====

[解决办法]


select * from table where yourTimeColumn >date_add(CURDATE() , INTERVAL 6 MONTH);.
==== 思想重于技巧 ====

[解决办法]


推荐你看一下这些帮助


SQL 1992
MySQL 5.1 Reference Manual
ActiveX Data Objects 2.5 Reference 下载
数据库系统概论PPT.
==== 思想重于技巧 ====

[解决办法]

SQL code
select * from tablename where date_field between date_sub(now(),interval 6 month) and now(); 

读书人网 >Mysql

热点推荐