- 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
UNIX_TIMESTAMP with date in MySQL query to fetch records after a specific date in different format?
For this, you can use STR_TO_DATE(), since we have date records in the following format: 21/11/2019.
Let us first create a table −
mysql> create table DemoTable1808 ( AdmissionDate varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1808 values('21/11/2019'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1808 values('01/01/2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1808 values('26/09/2017'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1808;
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 21/11/2019 | | 01/01/2018 | | 26/09/2017 | +---------------+ 3 rows in set (0.00 sec)
Here is the query to fetch records after a particular date −
mysql> select * from DemoTable1808 where str_to_date(AdmissionDate,'%d/%m/%Y') > '2018-12-31';
This will produce the following output −
+---------------+ | AdmissionDate | +---------------+ | 21/11/2019 | +---------------+ 1 row in set (0.00 sec)
- Related Articles
- MySQL query to fetch date records greater than the current date after adding days with INTERVAL?
- MongoDB query to fetch date records (ISODate format) in a range
- MySQL query to fetch the latest date from a table with date records
- Set a specific Date Format in MySQL?
- MySQL query to select records with a particular date?
- How to filter a query on specific date format with MongoDB?
- Fetch ordered records after a specific limit in MySQL
- Format date while inserting records in MySQL
- MySQL time period query to fetch date records from interval of 14 weeks from current date?
- MySQL query to fetch date with year and month?
- Display records after a particular date in MySQL
- Find records on or after a specific date in MongoDB?
- Convert VARCHAR Date to a different format in MySQL?
- Calling NOW() function to fetch current date records in MySQL?
- MySQL query to select records with a particular date and time?

Advertisements