I want to filter a layer with a variable and a LIKE condition.
The filter attribute is a timestamp column of Spatialite table. The table has also a join.
I successfully can filter this vector layer with:
layer_subset = layer.getFeatures( QgsFeatureRequest().setFilterExpression ( u'"acq_dat" LIKE \'27.06.2017%\'') )
27.06.2017 is the part of the timestamp string
Currently I'm writing a small plugin for exporting Shapefiles based on different dates. With a combo box the user can choose a date und this will be the variable for the filter.
I tried this:
layer_subset= layer.getFeatures( QgsFeatureRequest().setFilterExpression ( u'"acq_dat" LIKE \'%s%\'' % acq_dat ) )
But I get the error:
Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: not enough arguments for format string
How can I set a filter variable with a LIKE condition?