I am newbie in mongodb and trying to query a document based on date and it is not working.
db.orders.insertOne({ _id: 6, item: "chocaltes" , qty: 1, price: 10, order_date: {"$date": 1322006400000}})
Details:
mongodb version: 6.0.12
Find Query:
db.orders.find({order_date: ISODate("2011-11-23T00:00:00Z" )})
it should return the document.

This inserts a document into the collection. And, any of the following two queries return that document.
Note the
order_datefield. It is of typeobject, with one embedded field$date. As of MongoDB version 5, you can have field names starting with$sign (see Field Names with Periods (.) and Dollar Signs ($)).So, the value for the embedded field
order_date.$dateis a of data typedoublewith a value1322006400000.This will not return the document.
To return a document using the date
ISODate("2011-11-23T00:00:00Z")you will need a query like this:Note the usage of
$getFieldoperator. This is for using the field names with$sign. The$toDateconverts the number1322006400000to a date type. The$toDateis an aggregation operator. To use an aggreation operator in afindquery you need to use the$exproperator.