0

I'm working on a Drupal 8 site where I use a exposed filter to filter on date. I created a simple version of what I want on simplytest.me.

In this example I created a article with a start and end date.

Start date is 28-02-2018 01:00:00
End date is 28-02-2018 10:00:00

I also created a view with two exposed filters to filter on date range.

Exposed filter 1: >= Startdate
Exposed filter 2: <= Enddate

enter image description here

enter image description here

enter image description here

When I add 28-02-2018 in both filters the result is null. When I look in the query, I see it says 2018-02-27 instead of 2018-02-28

What is going wrong? It looks like it doesn't see the is equal to part of my filter.

enter image description here

Is this normal? How do I make this filter work as I expect?

I tried to fix it with https://www.drupal.org/project/drupal/issues/2627512#comment-12382345, but this only adds an hour, not a full day.

1 Answer 1

1

A friend of mine helped me out, the problem was me not adding time to the search query. I found this already along the way in finding a solution but I didn't understand it at that moment. Now I do.

By not entering a time in the search field (so searching for 28-02-2018) the search will go to 28-02-2018 00:00:00 which is the same as 27-02-2018 23:59:59.

So what I had to do was search for 28-02-2018 23:59:59 instead, when entering this in the search field, the right items do show.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.