question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

filter on specific date without caring about min/sec

See original GitHub issue

what is a good way to filter on specific date? I am storing data as full date format with timezone like 2018-08-06T14:21:54+02:00 and I am trying to query for specific day like: 2018-08-06 There are only few functionalities available for Date field and none support something like includes. Any suggestion?

ps: I know one solution would be making a function/store procedure in Postgres and then call it in the graphql but that is quite limited.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
benjiecommented, Aug 9, 2018

Personally I’d stick with the “greaterThanOrEqualTo” / “lessThan” combo - it’s more flexible and more explicit. All my databases use UTC. I’m not comfortable exposing a “like” operator - serious performance/DOS issues there; beginsWith would be better.

1reaction
mattbretlcommented, Aug 8, 2018

You’re right. Currently you’d have to write something like:

query {
  allFoos (filter: {
    bar: {
      greaterThanOrEqualTo: "2018-08-06",
      lessThan: "2018-08-07"
    }
  }) {
    nodes {
      bar
    }
  }
}

I can think of a few approaches:

  1. Expose the existing like operator, which would translate { bar: { like: "2018-08-06%" } } to a where clause of bar::text LIKE '2018-08-06%'. This would be also support queries on year, year-month, year-month-day-hour, etc.

  2. Create a new dateEqualTo operator, which would translate { bar: { dateEqualTo: "2018-08-06" } } to a where clause of bar::date = '2018-08-06'. This would likely be more performant, especially with an expression index.

@benjie, any thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filter by date | Algolia
Dates aren't only useful for sorting. You can also leverage them to filter search results on a specific date range. Imagine you have...
Read more >
10.3 Dates and times with lubridate - Bookdown
The answer clearly depends on the month in question (e.g., July is longer than June, and both are longer than February) and can...
Read more >
SQL Unable to filter for a specific date with Group By
Without access to your data this is slightly speculative, but it looks like you're picking up items which have a later exp_date ....
Read more >
Using date_start and date_end with date filters | Looker
When there is no value specified for date_filter , both {% date_start date_filter %} and {% date_end date_filter %} will evaluate to NULL...
Read more >
mSpy™ Cell Phone Tracker: Your #1 Monitoring Tool
Keep your children safe both online and in the real world with our mSpy™ parental tracking app. Monitor their GPS location, see who...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found