How to compare datetime in dgraph?

If i have date in this format UTC “2017-06-08 08:32:12 UTC”
What is the correct way to filter by date?


  query(func: has(cars), first: 10)  @filter(eq(status, "Active") AND le(create_date, "2018-01-20 08:32:12 UTC"))

That looks correct, do you have the datetime schema type on create_date?

I have set type datetime for create_date. Now it is giving me parse_error **: parsing time "2017-06-08 08:32:12 UTC": extra text: -06-08 08:32:12 UTC**

Simple query result, when i changed type to string:

 "query": [
        "create_date": "2017-06-08 08:32:12 UTC"    

The values for datetime need to be in RFC3339 format. See

I suppose you were able to input a value which is not in RFC3339 and then while indexing those values were ignored. If you value is in correct format, you can use le and ge functions to compare the dates and get records created in last hour or n seconds as well.