Last day of last month user filter

  • 3 March 2020
  • 3 replies

Hi All,

How can I use the advanced filter to create a filter to query the last day of last month?

Or, should this be done in a customer filter?

I have a date field and would like to have a relative filter to always filter last day of last month.

Any suggestion is appreciated 😃



3 replies

Userlevel 4

When you say the last day of the last month, I assume mean the last day of the previous month. The last of the day of the last month could be interpreted as always being December 31st.

A custom filter like the following should do the job:

${your_date_field} = add_days(-1, trunc_months(now()))

Ahh sorry. Of course. I translated from my own language 😃 You’re right I meant previous month.

Ok, I don’t get this to work but I see that “add_days(-1,trunc_months(now()))” gives me exactly the date I want so I’m doing something wrong.

Userlevel 7
Badge +1

@cristian assume today’s date `2020-03-04’

The trunc_months() function truncates the date to the beginning of that months, which would return 2020-03-01. For each date it would always return year-month-01

Now you are substracting one day from that date and get 2020-02-29