[GIS] QGIS filter by date in attribute table

datefilterqgis

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')

Best Answer

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!

Related Question