0

Fetching statements with the use of pipeline and curl, usually all good unless it is timestamp field. I've seen examples of how to query by timestamp on Learning Locker but it does not work for me.

$pipeline = '[
        {"$project": {"statement": 1}},
        {"$match": {"$and":
                [
                    {"timestamp" : {"$gte": {"$dte": "2019-01-01T00:00:00.000Z"}}}
                ]}
        }
    ]';

need to fetch all statements with timestamp $gte 2019.01.01 (later will do from 2019-01-01 to 2019-08-01

on fetch it will show like string "timestamp" => "2019-02-06T11:20:34+02:00"

  • Can you give me sample docs from your collection, When you say timestamp do you mean time in ms : '1232432424324' or ISO Date : '2019-01-01T00:00:00.000Z'? – whoami - fakeFaceTrueSoul Aug 09 '19 at 15:46
  • it shows like '2019-01-01T00:00:00.000Z' but it looks like string, does not show that it is ISO Date "timestamp": "2019-02-06T11:20:34+02:00" – Testas Testauskas Aug 12 '19 at 06:54
  • Ok, If its an ISO Date you need just pass ISO Date('your date') in your query or if it's a string you need to pass string in your query !! I would say give it a try with out $dte. – whoami - fakeFaceTrueSoul Aug 12 '19 at 15:01
  • I tried many ways, here I display how it is shown in documentation – Testas Testauskas Aug 13 '19 at 06:56
  • Check type of that field, you'll get to know what's the issue is. Also you don't need $and operation over there, Plus why is that $dte for ? Can you provide you sample documents, easy way is to if you use robo3T or mongoCompass just check type of timestamp !! If it's a String you can just do :::>> {"$match": {"timestamp" : {"$gte": "2019-01-01T00:00:00.000Z"}}} or if it's Date then :::>>{"$match": {"timestamp" : {"$gte": ISODate("2019-01-01T00:00:00.000Z")}}} – whoami - fakeFaceTrueSoul Aug 13 '19 at 06:59
  • 1
    this is the problem - I do not have access to documents. I use side service LRS that store documents on their server – Testas Testauskas Aug 13 '19 at 07:06

0 Answers0