Search code examples
pythonmongodbeve

Python Eve - How to filter by datetime value


How can I return items filtered by date or date interval? I was trying something like this based on the filtering example from eve's documentation:

/records/?where={"date": {"$gte": "2016-10-17"}}

I was thinking this python syntax could work too by checking this comment in eve's request parsing code:

/records/?where=date==datetime('2016-10-16')

But the result is 500 internal error, maybe the syntax is wrong. I'm having a hard time getting it right.

Thanks.


Solution

  • Try this:

    /records?where={"date": {"$gt": "Mon, 17 Oct 2016 03:00:00 GMT"}}
    

    It uses the DATE_FORMAT setting which defaults to RFC1123.