MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

mongodb:come filtrare i record creati oggi?

Supponendo che tu possa ottenere la data corrente....

// the start of the day (midnight)
begin_date_range = ISODate("2012-06-12T00:00:00Z");

// the start of the next day (at midnight)
// this can also be done with 11:59:59PM of the current date using $lte
end_date_range = ISODate("2012-06-13T00:00:00Z");

results = db.collection_name.where({"chashi_ts":{
              "$gte":begin_date_range,
              "$lt":end_date_range}
          );