I have a WFS data, which I'm trying to filter by DATE. I'm using query builder. I need to filter valid dates which are max three years older than current date. I can do it if I calculate three years my self, like "DATE" >= '2018-05-10T00:00:00.000'. Is there any expression that calculates that automatically every day, and shows only features that are valid?

1 Answer 1


You can use the value now() that returns the current date/time and subtract from it the value of your DATE field. Convert that to years with the function year(). If the result is greater than three, you want to skip it - see on the screenshot where I used the expression 3 > year (now() - "DATE" ) to select the DATES that are less than 3 years old.

Use a virtual field to always update the value.

enter image description here

  • Thank you for yor advice. I had troubles and I didn't succeed, maybe too much for my skills, but I heard a another way to try. Idea is to use rule based symbology with filter year( now() ) - "DATE" <=3 and that seems to work.
    – Juha
    May 12, 2021 at 7:36

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.