Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To use date range in a mongoexport query on Linux, you can use the "$gte" and "$lt" operators with the ISODate format in the query. Here is an example:

mongoexport --db mydatabase --collection mycollection --query '{ "date_field": { "$gte": ISODate("2022-01-01T00:00:00.000Z"), "$lt": ISODate("2022-02-01T00:00:00.000Z") } }' --type csv --fields field1,field2 --out output.csv

In this example, the query exports data from the "mycollection" collection where the "date_field" value is between January 1, 2022, and January 31, 2022. You can modify the ISODate values to specify your desired date range.