MongoDB导出日期解析问题
-
当我使用MongoExport.exe执行日期范围搜索的时候,它会一直把“05-2017”解析为“2006”
C:\Program Files\MongoDB\Server\3.4\bin>mongoexport.exe /h servername /p 27017 /d database /c collection /q "{'received_time': { '$gte' : {'$date':'19-05-2017'}, '$lte' : {'$date':'20-05-2017'}}}" 2017-05-22T20:36:31.685+0100 error validating settings: parsing time "19-05-2017" as "2006-01-02T15:04:05Z07:00": cannot parse "5-2017" as "2006" 2017-05-22T20:36:31.686+0100 try 'mongoexport --help' for more information
但是如果我在MongoDB Compass中运行以下命令的话,它就会正确的执行.
{received_time: { $gte : {$date:"2017-05-19"}, $lte : {$date:"2017-05-20"}}}
请问有什么办法可以解决这个问题吗?
-
看起来只是日期格式的问题。试一下yyyy-MM-dd的格式呢?