Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要做SELECT count(*) FROM users where created_at within 3 days ago
SELECT count(*) FROM users where created_at within 3 days ago
Created_at 是日期时间列。
用于三天前的日期:
WHERE t.date >= DATE_ADD(CURDATE(), INTERVAL -3 DAY);
检查DATE_ADD文档。
或者您可以使用:
WHERE t.date >= ( CURDATE() - INTERVAL 3 DAY )