Using QGIS 2.16.2, I can successfully select records from a shapefile attribute table using the following expression:

left("start_time", 10) = '2015-08-01'

Please note that start_time is a string field.

However, when I copy and paste the same expression into the shapefile's Layer Properties>General>feature filter>Query Builder I get the following error:

enter image description here

I would expect that the same expression would work everywhere in QGIS. What am I doing wrong?

1 Answer 1


Your observation is correct, The Query Builder does not use the same syntax as the rest of QGIS.

Throughout QGIS, the syntax is based on QGIS Expressions a customized SQL dialect. This is portable between almost all parts of QGIS where you can enter a filter, calculate a value... This syntax is parsed and evaluated directly in QGIS (and parts of it may be sent to the provider sometimes).

The provider feature filter defined via query builder (also often referred to as subset string) for the layer works different in the way that QGIS does not look at it at all. All it does is send it to the provider. In this case the provider is OGR which only supports a subset of the SQL syntax but sometimes it's very powerful, e.g. when accessing a postgres/postgis database.

  • 1
    Good to know. I used the following query in the filter, and it correctly replaced the selection that I previously tried: "start_time" LIKE '2015-08-01%'
    – Stu Smith
    Sep 29, 2016 at 6:20

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.