

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 dates between current date and 3 months from the current date in MySQL?
Use BETWEEN and INTERVAL to achieve this. Let us first create a table −
mysql> create table DemoTable -> ( -> AdmissionDate date -> ); Query OK, 0 rows affected (0.84 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-09-30'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('2019-10-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-03-30'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('2019-04-24'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+---------------+ | AdmissionDate | +---------------+ | 2019-09-30 | | 2019-10-01 | | 2019-03-30 | | 2019-04-24 | +---------------+ 4 rows in set (0.00 sec)
Following is the query to select dates between current date and 3 month from the current date in MySQL −
mysql> select *from DemoTable WHERE AdmissionDate BETWEEN curdate() - INTERVAL 3 MONTH AND curdate();
Output
+---------------+ | AdmissionDate | +---------------+ | 2019-03-30 | | 2019-04-24 | +---------------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL query to select date >= current date - 3 weeks?
- MySQL query to order and display difference between dates from the current date
- MySQL select * and find record with current date
- Find the difference between current date and the date records from a MySQL table
- MySQL DATE function to return the difference between current date and joining date
- MySQL query to get the current date from the list of dates
- Select a column if condition is met in MySQL to fetch records from current date and current date + 1
- Add some months to current date using Java with MySQL?
- MySQL query to retrieve current date from a list of dates
- How to select a date less than the current date with MySQL?
- Comparison of varchar date records from the current date in MySQL
- Select the date records between two dates in MySQL
- How to get the difference between date records and the current date in MySQL?
- Java Program to subtract months from current date using Calendar.add() method
- How do I calculate the date six months from the current date using the datetime Python module?
Advertisements