
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
How to work Date query with ISODate in MongoDB?
Use $gte operator along with ISODate() to work Date query with ISODate in MongoDB.
To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −
> db.dateDemo.insertOne({"StudentName":"John","StudentAge":26,"AdmissionDate":new ISODate("2013-06-07")}); { "acknowledged" : true, "insertedId" : ObjectId("5c8a65799064dcd4a68b70ea") }
Display all documents from a collection with the help of find() method. The query is as follows −
> db.dateDemo.find().pretty();
The following is the output −
{ "_id" : ObjectId("5c8a65799064dcd4a68b70ea"), "StudentName" : "John", "StudentAge" : 26, "AdmissionDate" : ISODate("2013-06-07T00:00:00Z") }
Here is the date query with ISODate in MongoDB −
> db.dateDemo.find({"AdmissionDate":{"$gte": ISODate("2013-06-07T00:00:00Z")}}).pretty();
The following is the output −
{ "_id" : ObjectId("5c8a65799064dcd4a68b70ea"), "StudentName" : "John", "StudentAge" : 26, "AdmissionDate" : ISODate("2013-06-07T00:00:00Z") }
- Related Articles
- MongoDB query to fetch date records (ISODate format) in a range
- Get component of Date / ISODate in MongoDB?
- How to work with variables in MongoDB query
- How to filter a query on specific date format with MongoDB?
- Converting isodate to numerical value in MongoDB?
- How to work with Stored JavaScript in MongoDB?
- How to query MongoDB with “like”?
- Return query based on date in MongoDB?
- MongoDB query to get date records in a range
- How to match date with MongoDB $match?
- How to query with nand operator in MongoDB?
- How to query MongoDB with a LIMIT?
- How to insert a document with date in MongoDB?
- Fetch month, day, year, etc. from ISODate in MongoDB?
- MongoDB query to get specific month|year (not date)?

Advertisements