【mongoDB】mongoDB根据时间条件查询
2022-04-16 本文已影响0人
放纵不基
$ mongoexport -h xx.xx.xx.xx \
--port=27017 \
--username=username \
--password='password' \
--authenticationDatabase=admin \
-d logstat \
-c T_LoginOut \
-q '{"$and":[{"sendTime":{"$gt": new Date(1598889600000)}},{"sendTime":{"$lt": new Date(1601481600000)}}]}' \
--type json \
-o T_LoginOut.json
#######################
$ mongo --host xx.xx.xx.xx:27017 --username=username --password='password' --authenticationDatabase=admin
> db.T_Test.count({"$and":[{"day":{"$gte": ISODate("2020-12-31T16:00:00.000Z")}},{"day":{"$lte": ISODate("2021-07-30T15:59:59.999Z")}}]})