Date Filtering eq is Useless

Hardly ever do I need to find a node by the exact date to the second which is what the eq filter does.

Most often I need to find nodes that match dates based upon the hour, day, month, year.

Right now to do any of these we have to use the between filter.

Use Case Example

type Task {
  id: ID
  name: String
  due: DateTime @search
}
query thisHour {
  queryTask(filter: { due: {
    # eq: "2020-03-10T12"
   between: { min: "2020-03-10T12:00:00", max: "2020-03-10T12:59:59" }
  } }) {
    id
  }
}
query today {
  queryTask(filter: { due: {
    # eq: "2020-03-10"
   between: { min: "2020-03-10T00:00:00", max: "2020-03-10T23:59:59" }
  } }) {
   id
  }
}
query thisMonth {
  queryTask(filter: { due: {
    # eq: "2020-03"
   between: { min: "2020-03-01T00:00:00", max: "2020-03-31T23:59:59" }
  } }) {
   id
  }
}
query thisYear {
  queryTask(filter: { due: {
    # eq: "2020"
   between: { min: "2020-01-01T00:00:00", max: "2020-12-31T23:59:59" }
  } }) {
   id
  }
}

I have to do all of these time calculations in my app to get the first and last second of this hour, day, month, year. The month one is the really tricky one. I could add a bug on purpose and call it a feature that if the task was due at midnight on the first of the month it shows due for the previous and the current month. Or I could make ugly filters and use ge and lt to include the beginning date but not include the end date.

Just looking for a way to be lazy in my app and let the server do some work on date calculations.

References:

^ my DateTime Functions topic includes more complicated date time functions such as every March no matter the year, while this topic is dealing with only an exact range: this Hour, Day, Month, Year.

2 Likes