Let us first create a table −
mysql> create table DemoTable -> ( -> Name varchar(100), -> DueDate datetime -> ); Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command. Let’s say the current date is “2019-07-05” −
mysql> insert into DemoTable values('Chris','2019-06-24'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Chris','2018-01-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Robert','2019-07-05'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Carol','2019-08-03'); Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+--------+---------------------+ | Name | DueDate | +--------+---------------------+ | Chris | 2019-06-24 00:00:00 | | Chris | 2018-01-01 00:00:00 | | Robert | 2019-07-05 00:00:00 | | Carol | 2019-08-03 00:00:00 | +--------+---------------------+ 4 rows in set (0.00 sec)
Here is the query to select all rows except those from today −
mysql> select *from DemoTable where date(DueDate) !=curdate();
This will produce the following output displaying the records ignoring the current date record −
Output
+-------+---------------------+ | Name | DueDate | +-------+---------------------+ | Chris | 2019-06-24 00:00:00 | | Chris | 2018-01-01 00:00:00 | | Carol | 2019-08-03 00:00:00 | +-------+---------------------+ 3 rows in set (0.00 sec)