For the current day, you can use CURDATE() method. Let us first create a table −
mysql> create table DemoTable -> ( -> DueDate date -> ); Query OK, 0 rows affected (1.35 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-06-14' ); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('2019-06-15'); Query OK, 1 row affected (0.64 sec) mysql> insert into DemoTable values('2019-06-16'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('2018-01-16'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable values('2018-07-16'); Query OK, 1 row affected (0.53 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------+ | DueDate | +------------+ | 2019-06-14 | | 2019-06-15 | | 2019-06-16 | | 2018-01-16 | | 2018-07-16 | +------------+ 5 rows in set (0.00 sec)
Following is the query to get records from the same day −
mysql> select *from DemoTable where DATE(DueDate)=CURDATE();
This will produce the following output −
+------------+ | DueDate | +------------+ | 2019-06-16 | +------------+ 1 row in set (0.03 sec)