I am trying to filter features within a shapefile for a specific date range. In the shapefile, one of the attributes is "date" and I would like to be able to filter it so it only shows a specific date range at all times. Basically I need it to show all features where the "date" is from the 22nd of the previous month to the 21st of the current month. I have worked out how to show the whole of the previous month or whole of current month but cannot seem to filter by day as well as month.

Something along the lines of:

"date" > year($now), month($now-'1'), day('21') AND "date" < year($now), month($now), day('22')

  • 1
    It surely depends on the format in which you have saved the date,
    – AndreJ
    Aug 23, 2016 at 15:56

1 Answer 1


Not to worry, I managed to answer my own question in the end, just couldn't work out the syntax. I needed to use

(year("ISSUED")=year($now) AND month("ISSUED")=month($now-'1 month') and day("ISSUED") > 21) OR (year("ISSUED")=year($now) AND month("ISSUED")=month($now) and day("ISSUED")<22)

There is probably a much more elegant solution than this but it works for me for the time being!

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.