- 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
Comparison of varchar date records from the current date in MySQL
For date comparison, you can use STR_TO_DATE(). Following is the syntax −
select * from yourTableName where str_to_date(yourColumnName,'yourFormatSpecifier') > curdate();
Let us first create a −
mysql> create table DemoTable1397 -> ( -> AdmissionDate varchar(40) -> );s Query OK, 0 rows affected (0.97 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1397 values('01/04/2019'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1397 values('27/09/2019'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1397 values('29/09/2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1397 values('29/09/2019'); Query OK, 1 row affected (0.08 sec)
Display all records from the table using select −
mysql> select * from DemoTable1397;
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 01/04/2019 | | 27/09/2019 | | 29/09/2018 | | 29/09/2019 | +---------------+ 4 rows in set (0.00 sec)
Let us first find the current date −
mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-09-27 | +------------+ 1 row in set (0.00 sec)
Following is the query to compare varchar date with the current date in MySQL −
mysql> select * from DemoTable1397 -> where str_to_date(AdmissionDate,'%d/%m/%Y') > curdate();
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 29/09/2019 | +---------------+ 1 row in set (0.07 sec)
- Related Articles
- Find the difference between current date and the date records from a MySQL table
- MySQL time period query to fetch date records from interval of 14 weeks from current date?
- MySQL query to get the current date records wherein one of the columns displays current date
- Display records from the current date till rest of the same month in MySQL?
- How to get the difference between date records and the current date in MySQL?
- Fetch records from interval of past 3 days from current date in MySQL and add the corresponding records
- Select a column if condition is met in MySQL to fetch records from current date and current date + 1
- Display all records ignoring the current date record in MySQL
- Select dates between current date and 3 months from the current date in MySQL?
- How to get the records of the last two days from the current date in MySQL?
- Condition to check for due date and current date records in MySQL where clause
- Convert varchar to date in MySQL?
- Calling NOW() function to fetch current date records in MySQL?
- Fastest way to search for a date from the date records in MySQL
- Get maximum date from a list of varchar dates in MySQL

Advertisements