1

I'm trying to set up Grouped filters for Content revision: Changed in a view. I want the filter to work for Today, Yesterday, Last week, Last month, and Last year. The grouped filters makes that simple enough, and it looks like this:

enter image description here

But all the filters are not filtering correctly.

For the Today filter, this will work.

enter image description here

But When I try to use an Is between operator for any previous dates, I get an error like this

enter image description here

How do I filter for previous time periods in views?


The Today filter works with Is greater than or equal to today midnight. It's the Is between parameters that the view won't accept.

The existing Today filter query adds

 AND ((node_field_revision.changed >= 1597759242-68400))

to the query, which converts to

GMT: Tuesday, August 18, 2020 2:00:42 PM - 19 hours.

Setting the Yesterday filter with Is less than or equal to yesterday adds

AND ((node_field_revision.changed <= 1597759395-154800))

to the query, which converts to

GMT: Tuesday, August 18, 2020 2:03:15 PM - 43 hours

which means the filter will show values from yesterday and today. That's not a yesterday filter.

So Is between is the way to go, but any values I try, including yours @Yuseferi, aren't accepted in the UI and so can't adjust to the query accordingly. If the view would accept an Is between operator, the query would add something like this:

AND ((node_field_revision.changed <= 1597759956-(1597723200-1597636800))

Where

Now: 1597759956
Today: 1597723200
Yesterday: 1597636800

That would be a yesterday query, which Drupal could then adjust for GMT.

1
  • Did you try reversing the inputs for yesterday? Also, those aren't offsets. You might need "-2 day" for the first and "-1 day" for the second
    – beltouche
    Commented Aug 17, 2020 at 22:01

1 Answer 1

0

I would suggest

data between today 1 sec ago and yesterday

Your Answer

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

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