[Qgis-user] Filter syntax for date fields

Alexandre Neto senhor.neto at gmail.com
Fri Oct 20 03:14:06 PDT 2017


Hi,

Vector Layer filtering SQL syntax is limited to the data provider. If you
are using a shapefile, then the provider is GDAL and you are limited to
this operands:


http://www.gdal.org/ogr_sql.html

If you used Geopackage or Spatialite or PostGIS you would probably have
more datetime specific operands that might work with your field.

Alexandre Neto

A sex, 20/10/2017, 03:30, Patrick Dunford <blackwhitekez at gmail.com>
escreveu:

> I have a shapefile table with 300,000 records of polygons that I want
> to filter for display on the map canvas. I want to use the field called
> "date" which is defined as a Qdate in the fields list in the
> shapefile's properties.
>
> The question is how to put in the filter string in the correct syntax
> to give me for example all the records that are for the calendar year
> of 1984.
>
> For example
>  year("date") = 1984
> will not work because it doesn't accept the year function from the list
> of functions that are available in other expression editors which allow
> a function list to be used.
>
> In a previous version of this table I had it was actually quite easy
> because the dates were input as a string and the like operator could be
> used. It seems with a date that is actually defined as a date field
> there is no obvious or easy way to input a range of dates (how do you
> put in a date constant) or use a function that will extract part of a
> date from a date field.
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

-- 
Alexandre Neto
---------------------
@AlexNetoGeo
http://sigsemgrilhetas.wordpress.com
http://gisunchained.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20171020/7b77a5e7/attachment.html>


More information about the Qgis-user mailing list