How to search within a time range, rather than date range?

Another newbie question I’m afraid.

Is there a way to find all nodes that contain a datetime between the times of 17:00 and 19:00, but ignoring the date part? I’ve tried playing around in ratel to see if I can achieve this, and searched and searched. One solution I’ve thought of is to save the time separately in a different datetime triple where the date is set to Jan 1, 1970. That will probably work but it doesn’t feel very elegant. Is there a way to do this with a normal datetime?

Yes, you can mix “AND, OR and NOT” with Inequality

  • le less than or equal to
  • lt less than
  • ge greater than or equal to
  • gt greather than

https://docs.dgraph.io/query-language/#and-or-and-not

https://docs.dgraph.io/query-language/#inequality

No, cuz the indexing is by “datetime”

Check “DateTime Indices” https://docs.dgraph.io/query-language/#indexing

So I should just go with the solution of storing the time separately from the date then? Any plan of having separate “date” and “time” data types for this very reason?

The use case is, for example, “show me all classes taught by this teach after 18:00 in the last month”.

I believe there will be no support for Time just because the form adopted in the Dgraph can fit perfectly into what you want to do. Use a generic date if you need to.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.