
- 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
Display records from the current date till rest of the same month in MySQL?
Let us first create a table −
mysql> create table DemoTable ( BookingDate date ); Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-09-21'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('2018-09-10'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-09-10'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-09-08'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2016-09-18'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------+ | BookingDate | +-------------+ | 2019-09-21 | | 2018-09-10 | | 2019-09-10 | | 2019-09-08 | | 2016-09-18 | +-------------+ 5 rows in set (0.00 sec)
Following is the query from current date till rest of the month in MySQL −
mysql> select *from DemoTable where BookingDate between curdate() and last_day(curdate());
This will produce the following output −
+-------------+ | BookingDate | +-------------+ | 2019-09-21 | | 2019-09-10 | | 2019-09-08 | +-------------+ 3 rows in set (0.01 sec)
- Related Questions & Answers
- Comparison of varchar date records from the current date in MySQL
- Display all records ignoring the current date record in MySQL
- How to display first day and last day of the month from date records in MySQL?
- Fetch date records comparing with the current date’s day and month in MySQL
- Order by a single field and display rest of the records in the same order with MySQL
- Filter the records of current day, month and year in MySQL?
- Find the difference between current date and the date records from a MySQL table
- Display month names and year from a column with date records with MySQL
- Get Nth weekday of the month from a column with DATE records in MySQL
- MySQL query to get the current date records wherein one of the columns displays current date
- Display Timestamp before the current date in MySQL
- Fetch records from interval of past 3 days from current date in MySQL and add the corresponding records
- How to get the records of the last two days from the current date in MySQL?
- How to sum current month records in MySQL?
- How to display the count from distinct records in the same row with MySQL?
Advertisements