I have a collection with a timestamp field of type datetime.now():
"chashi_ts" : ISODate("2012-06-12T16:08:22.645Z")
With only mongodb commandline, how to find the records that the field's datetime points to today?
I have a collection with a timestamp field of type datetime.now():
"chashi_ts" : ISODate("2012-06-12T16:08:22.645Z")
With only mongodb commandline, how to find the records that the field's datetime points to today?
Assuming you can get the current date....
// 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}
);