How to check if datetime equal tomorrow in MySQL
You can use the following solution, using DATEDIFF
and DATE_ADD
:
SELECT *
FROM sales_order
WHERE DATEDIFF(created_at, DATE_ADD(CURDATE(), INTERVAL 1 DAY)) = 0;
or a simpler solution only using 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.