如果数据 created_at
Datetime 列等于明天日期,我想检索 mysql 表数据,例如:
SELECT * FROM sales_order where created_at = tomorrow_date;
最佳答案
您可以使用以下解决方案,使用 DATEDIFF
和 DATE_ADD
:
SELECT *
FROM sales_order
WHERE DATEDIFF(created_at, DATE_ADD(CURDATE(), INTERVAL 1 DAY)) = 0;
或仅使用 DATEDIFF
的更简单的解决方案:
SELECT *
FROM sales_order
WHERE DATEDIFF(created_at, CURDATE()) = 1
DATEDIFF()
returnsexpr1 − expr2
expressed as a value in days from one date to the other.expr1
andexpr2
are date or date-and-time expressions. Only the date parts of the values are used in the calculation. - from MySQL docs.
关于mysql - 如何在 MySQL 中检查日期时间是否等于明天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49871976/