- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Select the date records between two dates in MySQL
To select the date records between two dates, you need to use the BETWEEN keyword. Let us first create a table −
mysql> create table DemoTable681(AdmissionDate datetime); Query OK, 0 rows affected (0.75 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable681 values('2019-01-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-11-01'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-12-03'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable681 values('2019-07-03'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable681 values('2019-02-04'); Query OK, 1 row affected (0.34 sec) Display all records from the table using select statement:
mysql> select *from DemoTable681;
This will produce the following output −
+---------------------+ | AdmissionDate | +---------------------+ | 2019-01-21 00:00:00 | | 2019-11-01 00:00:00 | | 2019-12-03 00:00:00 | | 2019-07-03 00:00:00 | | 2019-02-04 00:00:00 | +---------------------+ 5 rows in set (0.00 sec)
Following is the query to select the date records between two dates −
mysql> select *from DemoTable681 where AdmissionDate between '2019-02-01' and '2019-12-01';
This will produce the following output −
+---------------------+ | AdmissionDate | +---------------------+ | 2019-11-01 00:00:00 | | 2019-07-03 00:00:00 | | 2019-02-04 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
- Related Articles
- Select dates between current date and 3 months from the current date in MySQL?
- Get the SUM of records between two given dates in MySQL
- MySQL query to get the dates between range of records displaying student’s Date of Birth?
- MySQL query to select all data between range of two dates?
- Display distinct dates in MySQL from a column with date records
- Filter dates from a table with DATE and NULL records in MySQL
- MySQL query to select records with a particular date?
- How to search date between two dates in MongoDB?
- SELECT MySQL rows where today's date is between two DATE columns?
- Perform MySQL search between two dates
- How to select between/before/after dates in MySQL conditionally?
- How to get the difference between date records and the current date in MySQL?
- How to query between two dates in MySQL?
- Display records by grouping dates in MySQL
- MySQL query to select records with a particular date and time?

Advertisements