1、2天:datediff(curdate(),dateline)=1 or 2 1、3月:DATE_ADD(curdate(),INTERVAL -1 MONTH)=1 or 3, 1、3周:DATE_ADD(curdate(),INTERVAL -1 WEEK)=1 or 3
近1天 select * from posts where dateline > curdate()-1 ;近2天 select * from posts where dateline > curdate()-2 ;
近1周 select * from posts where dateline > curdate()-7 ;select * from posts where dateline > DATE_ADD(curdate(),INTERVAL -1 WEEK) ; 近3周 select * from posts where dateline > curdate()-7*3 ;select * from posts where dateline > DATE_ADD(curdate(),INTERVAL -3 WEEK) ;
近1月select * from posts where dateline > DATE_ADD(curdate(),INTERVAL -1 MONTH) ;select * from posts where dateline > DATE_SUB(curdate(),INTERVAL 1 MONTH) ;近3月 select * from posts where dateline > DATE_ADD(curdate(),INTERVAL -3 MONTH) ;select * from posts where dateline > DATE_SUB(curdate(),INTERVAL 3 MONTH) ;
1、2天:datediff(curdate(),dateline)=1 or 2 1、3月:DATE_ADD(curdate(),INTERVAL -1 or -3 MONTH)=1 or 3, 1、3周:DATE_ADD(curdate(),INTERVAL -1 or -3 WEEK)=1 or 3
1、3月:DATE_ADD(curdate(),INTERVAL -1 MONTH)=1 or 3,
1、3周:DATE_ADD(curdate(),INTERVAL -1 WEEK)=1 or 3
select *
from posts where dateline > curdate()-1 ;近2天
select *
from posts where dateline > curdate()-2 ;
select *
from posts where dateline > curdate()-7 ;select *
from posts where dateline > DATE_ADD(curdate(),INTERVAL -1 WEEK) ;
近3周
select *
from posts where dateline > curdate()-7*3 ;select *
from posts where dateline > DATE_ADD(curdate(),INTERVAL -3 WEEK) ;
from posts where dateline > DATE_ADD(curdate(),INTERVAL -1 MONTH) ;select *
from posts where dateline > DATE_SUB(curdate(),INTERVAL 1 MONTH) ;近3月
select *
from posts where dateline > DATE_ADD(curdate(),INTERVAL -3 MONTH) ;select *
from posts where dateline > DATE_SUB(curdate(),INTERVAL 3 MONTH) ;
1、3月:DATE_ADD(curdate(),INTERVAL -1 or -3 MONTH)=1 or 3,
1、3周:DATE_ADD(curdate(),INTERVAL -1 or -3 WEEK)=1 or 3