How do I extract the created date out of a Mongo ObjectID
I'm using the Mongo shell to query my Mongo db. I want to use the timestamp contained in the ObjectID as part of my query and also as a column to extract into output. I have setup Mongo to create ObjectIDs on its own. My problem is I can not find out how to work with the ObjectID to extract its timestamp. Here are the queries I am trying to get working. The 'createdDate' field is a placeholder; not sure what the correct field is: //Find everything created since 1/1/2011 db.myCollection.find({date: {$gt: new Date(2011,1,1)}}); //Find everything and return their createdDates db.myCollection.find