Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Display record with today and tomorrow's date from a column with date record in MySQL
Let us first create a table −
mysql> create table DemoTable ( AdmissionDate date ); Query OK, 0 rows affected (0.87 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-08-24');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('2019-08-25');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('2019-08-20');
Query OK, 1 row affected (0.24 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 2019-08-24 | | 2019-08-25 | | 2019-08-20 | +---------------+ 3 rows in set (0.00 sec)
Following is the query to display record with today and tomorrow’s date −
mysql> select *from DemoTable where AdmissionDate IN(curdate(),curdate() + interval 1 day);
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 2019-08-24 | | 2019-08-25 | +---------------+ 2 rows in set (0.00 sec)
Advertisements
