我需要帮助确定如何从数据库表中按日期计算-30天 然后计算从今天起约有30天的发票数量
答案 0 :(得分:6)
从今天起减少30天内的PHP
echo date('Y-m-d', strtotime('-30 days'));
答案 1 :(得分:0)
在SQL中使用interval
,例如:
create temporary table tmp (
d timestamp not null default current_timestamp on update current_timestamp
);
insert into tmp values
(now() - interval 1 day),
(now() - interval 32 day),
(now() - interval 33 day),
(now() - interval 10 day);
select * from tmp where d between now() - interval 30 day and now();