[mapserver-users] Get current year in a CLASS EXPRESSION (mapfile)

Michael Smith michael.smith.erdc at gmail.com
Wed Mar 23 03:58:09 PDT 2016


Rather than adding a new column, you can create either a view or just
alter your select to add a year column derived from your date. Something
like

DATA "GEOMCOL from (SELECT a.*, to_char(datinter,'yyyy') as YEAR from
mytable) using unique gid using srid=4326"

And then just use the YEAR column in your EXPRESSION.

Mike

----
Michael Smith

US Army Corps
Remote Sensing GIS/Center
michael.smith at usace.army.mil




-----Original Message-----
From: mapserver-users <mapserver-users-bounces at lists.osgeo.org> on behalf
of wiltomap <wiltoma at gmail.com>
Date: Wednesday, March 23, 2016 at 6:17 AM
To: <mapserver-users at lists.osgeo.org>
Subject: [mapserver-users] Get current year in a CLASS EXPRESSION (mapfile)

>I have a mapfile defining a layer which is about leaks fixes on a drinking
>water network.
>
>I would like to write an EXPRESSION (inside a CLASS) to select all current
>year operations. I rely upon a PostgreSQL/PostGIS table which is storing
>leaks fixes dates in a DATE type field named "datinter" (format is
>YYY-MM-DD). For certain reasons I won't explain here (depending on the
>website general infrastructure), I can't add columns to the table to
>display
>year from the datinter column. I need to do it into the EXPRESSION
>parameter
>of my mapfile.
>
>I have tried things like this :
>
>CLASS
>  NAME "2016"
>  EXPRESSION ("[datinter]" > "2016-01-01")
>  ...
>END
>
>This kind of expression does filter some of the table rows but mixes
>different years... I don't understand what selection is made. Any idea on
>how to write the expression to achieve what I need?
>
>Thanks in advance!
>
>
>
>
>
>--
>View this message in context:
>http://osgeo-org.1560.x6.nabble.com/Get-current-year-in-a-CLASS-EXPRESSION
>-mapfile-tp5257968.html
>Sent from the Mapserver - User mailing list archive at Nabble.com.
>_______________________________________________
>mapserver-users mailing list
>mapserver-users at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list