Ask Your Question
2

How can I use date range in a mongoexport query on Linux?

asked 2021-08-20 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-10-26 11:00:00 +0000

pufferfish gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-20 11:00:00 +0000

Seen: 11 times

Last updated: Oct 26 '22