

- 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
Find lowest Date (custom) in MySQL?
To find lowest Date(custom) in MySQL, let us first create a table. The query to create a table is as follows:
mysql> create table FindMinimumDate -> ( -> Id int NOT NULL AUTO_INCREMENT, -> yourDay varchar(2), -> yourMonth varchar(2), -> yourYear varchar(4), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into FindMinimumDate(yourDay,yourMonth,yourYear) values('21','11','2019'); Query OK, 1 row affected (0.10 sec) mysql> insert into FindMinimumDate(yourDay,yourMonth,yourYear) values('20','10','2020'); Query OK, 1 row affected (0.38 sec) mysql> insert into FindMinimumDate(yourDay,yourMonth,yourYear) values('03','08','2014'); Query OK, 1 row affected (0.17 sec) mysql> insert into FindMinimumDate(yourDay,yourMonth,yourYear) values('04','09','2017'); Query OK, 1 row affected (0.12 sec) mysql> insert into FindMinimumDate(yourDay,yourMonth,yourYear) values('05','07','2013'); Query OK, 1 row affected (0.12 sec) mysql> insert into FindMinimumDate(yourDay,yourMonth,yourYear) values('25','12','2016'); Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from FindMinimumDate;
The following is the output:
+----+---------+-----------+----------+ | Id | yourDay | yourMonth | yourYear | +----+---------+-----------+----------+ | 1 | 21 | 11 | 2019 | | 2 | 20 | 10 | 2020 | | 3 | 03 | 08 | 2014 | | 4 | 04 | 09 | 2017 | | 5 | 05 | 07 | 2013 | | 6 | 25 | 12 | 2016 | +----+---------+-----------+----------+ 6 rows in set (0.00 sec)
Let us now find the lowest Date(Custom) in MySQL. The query is as follows:
mysql> select min(concat(yourYear,'-',yourMonth,'-',yourDay)) as MinimumDate from FindMinimumDate;
The following is the output displaying the lowest date:
+-------------+ | MinimumDate | +-------------+ | 2013-07-05 | +-------------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- Validate Date in MySQL using a custom function
- How to Insert custom date into MySQL timestamp field?
- Find the next lowest number higher than a certain number in MySQL?
- A single MySQL query to find the highest and lowest among two tables?
- How to find last date from records with date values in MySQL?
- Perform custom sorting in MySQL
- Find K items with the lowest values in C++
- Pull row with lowest number in a MySQL column?
- MySQL order by from highest to lowest value?
- MySQL select * and find record with current date
- Implement Custom Sort Order in MySQL
- Find date record after a particular date from a column with VARCHAR type in MySQL
- Convert UK DATE to MySQL date?
- Set MySQL select in a custom variable
- Find the difference between current date and the date records from a MySQL table
Advertisements