0

I have a Drupal7 view which includes a field of Date type (let's say "activity date") via a relationship. I want to filter this field by "today" (show only activities with activity date equal to today). (The module Date Views is installed.)

So I created a Filter on this field and this relationship, choose the Operator "is equal to" and the option "An offset from the current time such as "+1 day" or "-2 hours -30 minutes"" with the value "today". This returns 0 results, although I am sure I have activities with activity date == today.

Then, I tried the other operators, and it seems several of them are broken. Only "greater than or equal to" and "less than or equal to" work as expected. "Less than" + "today" as well as "Greater than" + "today" show also activities with activity date == today. "Is not equal to" + "today" shows all activities, also those with activity date == today. If I use the view without any date filters, these activities and their dates show correctly.

I even tried "Is between" + "today" + "today" which returns 0 results as well. "Is between" + "yesterday" + "tomorrow" returns all the activities from yesterday, today and tomorrow (so this means that the min and max values are inclusive, not exclusive, which is why today+today should work as well).

As "greater than or equal to" +today and "less than or equal to" +today work as expected, I thought I could put those two filters on the view together to achieve the results for "today", but both of them together return 0 results again.

Then, I tried to use a Contextual Filter. I could choose between the normal activity date field and the activity date field in the form of CCYYMMDD. When I choose the latter, and combine it with "Provide default value" > "Current date", this works, but the timezone is wrong and the day ends at 10 pm, so activities with a date after 10pm are not shown. I think the reason for that is the date form CCYYMMDD does not contain the time and thus UTC is used as default. When I use the normal activity date field and combine it with "Provide default value" > "Current date", it shows 0 results again.

How can I do this simple filter for the current date? It seems like a basic functionality to me.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.