

- 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
Get maximum date from a list of varchar dates in MySQL
Let us first create a table −
mysql> create table DemoTable ( AdmissionDate varchar(100) ); Query OK, 0 rows affected (0.76 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Sunday, 11 August 2019'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Friday, 18 October 2019'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Thursday, 18 July 2019'); Query OK, 1 row affected (0.23 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable ;
This will produce the following output −
+-------------------------+ | AdmissionDate | +-------------------------+ | Sunday, 11 August 2019 | | Friday, 18 October 2019 | | Thursday, 18 July 2019 | +-------------------------+ 3 rows in set (0.00 sec)
Following is the query to get the maximum date from a list of varchar dates inserted above −
mysql> select max(str_to_date(AdmissionDate,'%W, %d %M %Y')) AS MaxDate from DemoTable;
This will produce the following output −
+------------+ | MaxDate | +------------+ | 2019-10-18 | +------------+ 1 row in set (0.04 sec)
- Related Questions & Answers
- MySQL query to get the current date from the list of dates
- MySQL query to retrieve current date from a list of dates
- Comparison of varchar date records from the current date in MySQL
- Find maximum value from a VARCHAR column in MySQL
- Getting the maximum value from a varchar field in MySQL
- Searching BETWEEN dates stored as varchar in MySQL?
- Find date record after a particular date from a column with VARCHAR type in MySQL
- Convert varchar to date in MySQL?
- Display distinct dates in MySQL from a column with date records
- How to find a particular varchar id in MySQL from a list of values?
- Get a list of Constraints from MySQL Database?
- Filter dates from a table with DATE and NULL records in MySQL
- Convert VARCHAR Date to a different format in MySQL?
- Get the minimum and maximum value from a VARCHAR column and display the result in separate MySQL columns?
- Get maximum of Nth column from tuple list in Python
Advertisements