我试图选择日期来自上个月的最后一天或更早的数据,因此不应显示当前月份的数据。
询问:
SELECT * FROM payments WHERE request_date ...
并且不知道如何继续。
谢谢
尝试:
SELECT * FROM payments WHERE request_date < DATE_FORMAT(NOW(),'%Y-%m-01 00:00:00')
本月第一天凌晨 12:00 之前的任何内容。
SELECT * FROM payments WHERE request_date <= (curdate() - interval dayofmonth(curdate()) DAY);
SELECT * FROM payments WHERE request_date BETWEEN DATE_SUB(request_date, INTERVAL 1 MONTH)
这样的事情应该为你做:
SELECT * FROM payments WHERE DATE_SUB(CURDATE(),INTERVAL 31 DAY) >= request_date;
"SELECT * FROM payment WHERE request_date ='".data('Ymt',strtotime("-1 month",time()))."'"
尝试这个 :
SELECT * FROM payments WHERE datediff(now(),request_date)>30