
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to check if a datetime value equals tomorrows date in MySQL?
For this, you can use DATEDIFF(). Let us first create a table −
mysql> create table DemoTable -> ( -> ShippingDate datetime -> ); Query OK, 0 rows affected (0.90 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-07-01'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values('2019-07-02'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-07-03'); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values('2019-07-04'); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+---------------------+ | ShippingDate | +---------------------+ | 2019-07-01 00:00:00 | | 2019-07-02 00:00:00 | | 2019-07-03 00:00:00 | | 2019-07-04 00:00:00 | +---------------------+ 4 rows in set (0.00 sec)
Following is the query to check if datetime equals tomorrows date in MySQL or not −
mysql> select *from DemoTable -> WHERE DATEDIFF(ShippingDate, DATE_ADD(CURDATE(), INTERVAL 1 DAY)) = 0;
This will produce the following output displaying tomorrows date 2019-07-02 was one of the dates in the table −
Output
+---------------------+ | ShippingDate | +---------------------+ | 2019-07-02 00:00:00 | +---------------------+ 1 row in set (0.08 sec)
- Related Articles
- How to cast DATETIME as a DATE in MySQL?
- How to check if a date has passed in MySQL?
- How to convert JS date time to MySQL datetime?
- How to part DATE and TIME from DATETIME in MySQL?
- How to select only MySQL date from datetime column?
- How to update date of datetime field with MySQL?
- MySQL Query to convert from datetime to date?
- Insert current date in datetime format MySQL?
- Fetch date record that equals today in MySQL
- How to compare DateTime Column with only Date not time in MySQL?
- Adding a day to a DATETIME format value in MySQL?
- How to convert MySQL DATETIME value to JSON format in JavaScript?
- Create DATETIME from DATE and TIME in MySQL?
- Get only the date from datetime in MySQL?
- Check if the current date falls in a given date range using MySQL query

Advertisements