日期:2014-05-16  浏览次数:21185 次

用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();