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.
我需要我的查询来选择今年的第一个日期和当前日期之间的所有日期。(即今年数据库中的所有日期),但是我的代码在过去 12 个月内这样做。如何更改我的代码以确保其唯一日期从今年开始?
WHERE DATE_SUB(CURDATE(), INTERVAL 1 YEAR) <= date
非常感谢
SELECT ... FROM ... WHERE DATE_SUB(CURDATE(), INTERVAL 1 YEAR) <= date AND YEAR(your_datecolumn) = YEAR(CURDATE())
where created_date between MAKEDATE(YEAR(now()), 1) and now();
MAKEDATE(YEAR(now()), 1) 给你 '01/01/(thisyear)'