- 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
How to search a record by date in MySQL table?
Suppose we have a table ‘Order123’ having ProductName, Quantity and OrderDate columns as follows −
mysql> Select * from Order123; +-------------+----------+------------+ | ProductName | Quantity | OrderDate | +-------------+----------+------------+ | A | 100 | 2017-05-25 | | B | 105 | 2017-05-25 | | C | 55 | 2017-05-25 | | D | 250 | 2017-05-26 | | E | 500 | 2017-05-26 | | F | 500 | 2017-05-26 | | G | 500 | 2017-05-27 | | H | 1000 | 2017-05-27 | +-------------+----------+------------+ 8 rows in set (0.00 sec)
Now if we want to search how many orders received on a particular date say 25th June 2017 then it can be done as follows −
mysql> Select ProductName, Quantity from Order123 where OrderDate = '2017-05-25'; +-------------+----------+ | ProductName | Quantity | +-------------+----------+ | A | 100 | | B | 105 | | C | 55 | +-------------+----------+ 3 rows in set (0.00 sec)
Suppose we have stored the OrderDate with time as well then with the help of following query we can get the specified output −
mysql> Select ProductName, Quantity from Order123 where date(OrderDate) = '2017-05-25';
- Related Articles
- How can we search a record from MySQL table having a date as a value in it?
- How to insert date record to the same table with different date formats with MySQL?
- MySQL query to search record with apostrophe?
- How to search for a date in MySQL timestamp field?
- Display record with today and tomorrow’s date from a column with date record in MySQL
- How to search for ^ character in a MySQL table?
- How to delete last record (on condition) from a table in MySQL?
- How to get the second last record from a table in MySQL?
- Update record on a specific date matching the current date in MySQL
- How to search a MySQL table for a specific string?
- Insert record in a MySQL table with Java
- Delete a specific record from a MySQL table by using AND in WHERE clause
- How to select a specific record from MySQL if date is in VARCHAR format?
- How to change the date in a table with date records with MySQL?
- Update MySQL table column by matching date using date() function?

Advertisements