可以对日期等于当前日期 -7 到 +7 的日期列运行查询。
以今天(12 月 4 日)为例,查询将从 11 月 27 日返回到 12 月 11 日。
希望这是有道理的。
谢谢
凯伦
最佳答案
当然。假设您的列中只有日期(没有时间部分):
where datecol >= curdate() - interval 7 day and
datecol <= curdate() + interval 7 day
无论有没有时间组件,这都会起作用:
where datecol >= curdate() - interval 7 day and
datecol < curdate() + interval 8 day
请注意,这两者都返回 15 天的行。
关于MySQL 查询返回当前日期的 -7 到 +7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59178852/