Suppose you have historical data and want to filter data the last 3 months excluding this month. To do so, you can use relative dates filter.
On a filter dialog, select <relative dates> as Filter Operator, Last N Months (Exclude This Month) as How to Set Value. Then set 3 as Value.
this creates a filter below behind the scene.
between(date, floor_date(today(), unit = "month") %m-% months(3), floor_date(today(), unit = "month") %m-% days(1))
So the filter uses between operator and it uses two edges:
The first date of the 3 Months ago is calculated as floor_date(today(), unit = "month") %m-% months(3)
. And the last day of the last month is calculated as floor_date(today(), unit = "month") %m-% days(1)
For your reference, floor_date()
takes a date-time column and rounds it down to the nearest boundary of the specified time unit, in this example month. The floor_date function is from lubridate package.