- 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
Find records on or after a specific date in MongoDB?
To find records on or after a date, use $gte i.e., greater than equal. Let us create a collection with documents −
> db.demo91.insertOne({"ArrivalDate":new ISODate("2020-01-10")}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d49fd79799acab037af66") } > db.demo91.insertOne({"ArrivalDate":new ISODate("2019-12-14")}); { "acknowledged" : true, "insertedId" : ObjectId("5e2d4a0679799acab037af67") }
Display all documents from a collection with the help of find() method −
> db.demo91.find();
This will produce the following output −
{ "_id" : ObjectId("5e2d49fd79799acab037af66"), "ArrivalDate" : ISODate("2020-01-10T00:00:00Z") } { "_id" : ObjectId("5e2d4a0679799acab037af67"), "ArrivalDate" : ISODate("2019-12-14T00:00:00Z") }
Following is the query to find records on or after a specific date in MongoDB −
> db.demo91.find({ArrivalDate: { $gte: ISODate('2020-01-10') } });
This will produce the following output −
{ "_id" : ObjectId("5e2d49fd79799acab037af66"), "ArrivalDate" : ISODate("2020-01-10T00:00:00Z") }
- Related Articles
- UNIX_TIMESTAMP with date in MySQL query to fetch records after a specific date in different format?
- Find data for specific date in MongoDB?
- Find MongoDB records with Price less than a specific value
- Find MongoDB records based on a condition?
- Display records after a particular date in MySQL
- Fetch ordered records after a specific limit in MySQL
- How to filter a query on specific date format with MongoDB?
- GroupBy Date in MongoDB to count duplicate date records
- MongoDB query to get date records in a range
- Searching a specific domain name from URL records in MongoDB?
- MongoDB Query to search for records only in a specific hour?
- MongoDB query to fetch date records (ISODate format) in a range
- Find duplicate records in MongoDB?
- How to get latest set of data from a MongoDB collection based on the date records?
- Find specific records which has whitespace on the second place in MySQL

Advertisements