Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


MongoDB query based on timestamp

Posted on 2016-03-19
Medium Priority
Last Modified: 2016-10-25
I have mongoDB collection and for the documents added to the collection I used timestamp field to capture the current time stamp with this format:

I am looking for a find query to return all documents added to data base in past 24 hours.

I would appreciate your help.
Question by:artsec
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

Evan Cutler earned 2000 total points
ID: 41854554
Assuming your timestamp field is called "createdAt"

db.getCollection("COLLECTION_NAME").find({"createdAt":{$gt:new Date( - 24*60*60 * 1000)}})

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question