My documents are organized this way:
{
"_id" : ObjectId("5ea79b5da8d460059a5f58eb"),
"direction" : 0,
"metrictimestamp" : ISODate("2018-02-01T02:59:55Z"),
"odometer" : 19030291,
"routecode" : 0,
"speed" : 0,
"deviceid" : 8155064,
"vehicleid" : 34489,
"location" : {
"type" : "Point",
"coordinates" : [
-3.878595,
-38.533493
]
}
}
I need to "mongoexport" all the documents with tha same date, so i need a query that cuts the HH:MM:SS from the metrictime stamp field, thanks for your time!
To only export documents on a particular day use the $gt and $lt opperators and the --query arg on mongoexport like this:
https://docs.mongodb.com/v4.2/reference/program/mongoexport/#cmdoption-mongoexport-query
mongoexport -d=dbname -c=collection -q='{ "metrictimestamp": { "$gte": { "$date": "2018-02-01T00:00:00Z" }, "$lt": { "$date": "2018-02-02T00:00:00Z" } } }'