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
SET MONGOEXPORT="%ProgramFiles%\Alteryx\bin\mongoexport.exe"
FOR /f %%a IN (‘WMIC OS GET LocalDateTime ^| FIND “.”’) DO SET DTS=%%a
SET Date=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%
SET Time=%DTS:~8,2%:%DTS:~10,2%:%DTS:~12,2%%DTS:~14,4%Z
SET /a tztemp=%DTS:~21%/60
SET tzone=UTC%tztemp%
SET DateTime=%DTS:~0,4%%DTS:~4,2%%DTS:~6,2%_%DTS:~8,2%%DTS:~10,2%%DTS:~12,2%
SET JSON="{‘Timestamp’:{’$gte’:{’$date’:’%Date%T00:00:00.000Z’}}}"
I was using this batch script to export audit events in Mongodb4.0. now my environment is migrated to 4.2 and 4.4 . If i run the query now it s giving below error.
2022-09-14T12:33:33.389+0100 connected to: mongodb://localhost:27018/
2022-09-14T12:33:33.390+0100 Failed: error parsing query as Extended JSON: invalid JSON input
Can you clarify why and what modification should i do
Your set JSON variable on timestamp seems to be the issue
For extended json you have to enclose all fields,functions in double quotes and single quote outside the flower bracket
Check documentation for exact syntax/example
What is your os?
If it is Windows format will be different
Also your quotes around Timestamp look different.Use double quotes
Single quote outside flower bracket also look different
Check this thread for Windows query format Mongodump --query not able to filter using timestamp