MongoExport with query

MongoExport is working without query. when i try the below query getting erros
Shell version 4.2.8

-q=’{ “CreatedOnUtc”: { “$lt”: { “$date”: “2016-01-01T00:00:00.000Z” } } }’

Error message: error parsing command line options: too many positional arguments: [CreatedOnUtc: { $lt: { $date: 2016-01-01T00:00:00.000Z } } }’]

post screenshot of the whole command. your quotes are not shown correctly.


Also tried this

Hi @Ezi welcome to the community!

This is a common issue in Windows, since cmd doesn’t recognize single quotes as delimiters, unlike Linux.

Could you try switching your quotes around (single quotes to double quotes and vice versa) like this and see if it works?

-q="{ 'CreatedOnUtc': { '$lt': { '$date': '2016-01-01T00:00:00.000Z' } } }"

Best regards
Kevin

Thanks @kevinadi . When i try , still getting error

When I tried this query on my Windows it did not give any errors. Gave the message exported zero rows since I don’t have that collection nor field
Can you add some sample docs
Sometimes spaces cause issues and interpreted differently.Remove extra space after date:
or
Put your query in a json file and use queryfile option of mongoexport

When collection has zero row. No error. once have the error result have at least one doc.