0

How to run this mongodb command with json dates with mongodb rucommand or with mongo it always returns zero records . ref : https://jira.mongodb.org/browse/JAVA-565

      { "aggregate" : "dummy" , "pipeline" : [ { "$match" : { "$and" : [ { "myDate" : { "$gte" : { "$date" : "2017-07-25T18:30:00.428Z"}}} , { "myDate" : { "$lte" : { "$date" : "2017-11-02T18:29:59.428Z"}}}]}} , { "$project" : {  "year" : { "$year" : [ "$myDate"]} , "duration" : { "$month" : [ "$myDate"]}}} , { "$group" : { "_id" : { "year" : "$year" , "duration" : "$duration" , "orderType" : "$orderType"} , "count" : { "$sum" : 1}}} , { "$sort" : { "_id.year" : -1 , "_id.duration" : -1}}] , "cursor" : { "batchSize" : 1000}}

regards

kris

chiku
  • 485
  • 2
  • 8
  • 23
  • Your project stage looks incorrect. Try `{ "$project" : { "year" : { "$year" : "$myDate"} , "duration" : { "$month" : "$myDate"}}}` – s7vr Feb 23 '18 at 15:27
  • it SEEMS this issue is NOT RESOLVED interesting link https://jira.mongodb.org/browse/SERVER-6813 . Please help. Seems that mongodb will return ZERO records for strict DATE json, Ref : https://stackoverflow.com/questions/18370206/can-strict-json-dates-be-used-in-a-mongodb-query – chiku Feb 23 '18 at 15:50
  • 1
    Does it run without the date filter ? Why not change it to use ISODate() if you run from shell ? – s7vr Feb 23 '18 at 16:00
  • it runs without dates – chiku Feb 23 '18 at 16:13

0 Answers0