0

Lots of solutions to querying mongoDB using date/time field in MongoDB but what if the mongo doc doesn't have a date/time field?

I've noticed that when I hover the mouse over a document _id (using NoSQLBooster for MongoDB) I get a "createdAt" dropdown (see screenshot below). Just wondering if there is anyway to do a query using pymongo where documents are filtered based on a date/time range using their "createdAt" metadata?

screen shot of createdAt metadata

DaneOH-89
  • 50
  • 6

1 Answers1

1

In MongoDB the id of the docs contains the timestamp of creation, this is mentioned on this other question. You can make a script that insert a date/field using this information to perform those queries or perform the query directly to using the objectId as in here.

  • Legend! thanks! the answer contained in your last link [here](https://stackoverflow.com/questions/8749971/can-i-query-mongodb-objectid-by-date) was what I was after. It's written in Java but I should be able to adjust it to python with no worries. I'll let you know how I go! thanks again! – DaneOH-89 Feb 03 '20 at 07:11