Filter Datetime on month or day / advanced Datetime functions

I have a few domain problems, wich are tackling the problem to find nodes based on certain Datetime properties like month, day or hour.
Per year basis is easy with an index and a filter on datetime (use AND le gt etc.).
But i can not find any Datetime Filters/Operations/Functions to filter to month or day or hour like in SQL for a group by like query.

An example problem is to find all type Person who have birthday at a given date (not on that particular date - without year of course).
Another problem would be for data analysis, e.g. compare monthly, daily or hourly values to according past time periods etc.

However you could do such queries with your own custom “Date” type.
Just add extra attributes to the type Person for day, month and year and index them.
Since there could be very many nodes attached to the month index, you can create a custom designed index for the domain problem. Perhaps a “Birthday” type with month_day and relation to a Person type - so you get all Persons at once for a given month/date combination - could be more optimized than extra fields year, month and date with indexes on Person type.
Whats great on this custom solution is, that you can also use other values like weeks or shifts etc.

Besides the extra type and relation handling in dgraph these custom solutions always require application logic for what are quite “normal” Datetime operations.
You also loose the built in filter functions for Datetime, or you have to manage both and keep Datetime and your custom solution in sync.

Is there any better built in solution to filter by month/day or hour etc. - or is it planned?

2 Likes