
- 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 select rows in MySQL that are >= 1 DAY from the current date?
To get data greater than equal to 1 day from the current date, use the concept of INTERVAL in MySQL.
The current date is as follows −
mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-11-29 | +------------+ 1 row in set (0.00 sec)
We will first create a table −
mysql> create table DemoTable1806 ( DueDate datetime ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1806 values('2019-11-28'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1806 values('2019-11-29'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1806 values('2019-11-30'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1806 values('2019-11-25'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1806;
This will produce the following output −
+---------------------+ | DueDate | +---------------------+ | 2019-11-28 00:00:00 | | 2019-11-29 00:00:00 | | 2019-11-30 00:00:00 | | 2019-11-25 00:00:00 | +---------------------+ 4 rows in set (0.00 sec)
Here is the query to select rows which is >=1 day from the current date
mysql> select * from DemoTable1806 where DueDate >= now() - INTERVAL 1 DAY;
This will produce the following output −
+---------------------+ | DueDate | +---------------------+ | 2019-11-29 00:00:00 | | 2019-11-30 00:00:00 | +---------------------+ 2 rows in set (0.00 sec)
- Related Articles
- Selecting rows that are older than current date in MySQL?
- Select a column if condition is met in MySQL to fetch records from current date and current date + 1
- Select dates between current date and 3 months from the current date in MySQL?
- Select records from MySQL NOW() -1 Day?
- How to add 1 day to the date in MySQL?
- How to select a date less than the current date with MySQL?
- MySQL select query to select rows from a table that are not in another table?
- How to select a query for a selected day(2010-11-04) to current date using MySQL?
- MySQL query to select date >= current date - 3 weeks?
- Select last day of current year in MySQL?
- How to select date from timestamp in MySQL?
- How to select last 10 rows from MySQL?
- Grab where current date and the day before with MySQL?
- How to select all records that are 10 minutes within current timestamp in MySQL?
- MySQL select * and find record with current date

Advertisements