- 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
MySQL select * and find record with current date
For the current date, use CURDATE(). Also, use STR_TO_DATE() to format date and compare it with the current date as in the below syntax −
Syntax
select *from yourTableName where str_to_date(yourColumnName,'yourFormatSpecifier')=curdate();
Let’s say the current date is 27/10/2019.
Let us first create a table −
mysql> create table DemoTable -> ( -> JoiningDate varchar(40) -> ); Query OK, 0 rows affected (0.79 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('27/10/2017'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('27/10/2018'); Query OK, 1 row affected (0.78 sec) mysql> insert into DemoTable values('27/10/2019'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('27/10/2020'); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement−
mysql> select *from DemoTable;
This will produce the following output −
+-------------+ | JoiningDate | +-------------+ | 27/10/2017 | | 27/10/2018 | | 27/10/2019 | | 27/10/2020 | +-------------+ 4 rows in set (0.00 sec)
Following is the query to compare and find a record with the current date −
mysql> select *from DemoTable where str_to_date(JoiningDate,'%d/%m/%Y')=curdate();
This will produce the following output −
+-------------+ | JoiningDate | +-------------+ | 27/10/2019 | +-------------+ 1 row in set (0.00 sec)
- Related Articles
- How to select a date less than the current date with MySQL?
- Select dates between current date and 3 months from the current date in MySQL?
- Display record with today and tomorrow’s date from a column with date record in MySQL
- MySQL query to select date >= current date - 3 weeks?
- Update record on a specific date matching the current date in MySQL
- Display all records ignoring the current date record in MySQL
- Select a column if condition is met in MySQL to fetch records from current date and current date + 1
- MySQL date column auto fill with current date?
- Find date record after a particular date from a column with VARCHAR type in MySQL
- Insert record using MySQL SELECT?
- Select last record and update it in MySQL?
- Get timestamp date range with MySQL Select?
- How to select a specific record from MySQL if date is in VARCHAR format?
- Grab where current date and the day before with MySQL?
- MySQL query to select a record with two exact values?

Advertisements