Class or filter expression on date field in shapefile

Andreas Albarello andreas.albarello at TERRITORIUMONLINE.COM
Tue Oct 30 05:59:36 PDT 2007


Ei Fujioka wrote:
> I'm having difficulty in trying to filter features in a shapefile by dates.
> 
> I looked into this mailing list and have found a post saying "MapServer 
> doesn't support date types in shapefiles."
> This post is a very old one, dated in July 2000.
> 
> So I'm wondering if the latest Mapserver supports this. And if so, what 
> is the date format for class/filter expression?
> I use Mapserver 4.2.

Ei,

yes, this should be possible with more recent MapServer releases. I 
don't know whether it used to work back in the day of MapServer 4.2. You 
should really upgrade to 4.6 at least.

> Can't I use a string value like '2003-03-01' for date comparison?
> I tried the following expression but failed.
> EXPRESSION ([DATE_S] > '2003-01-01')
> 
> Is there any smarter way to filter on dates?

Yes, you need to explicitly tell MapServer that you want the field and 
your value to be treated as dates rather than strings. You do this by 
surrounding them with backticks (ASCII #96), for instance:

EXPRESSION (`[DATE_S]` > `2003-01-01`)

Best regards,
-- 
--------------------------------------------------------------------
Andreas Albarello
Analysis & SW Development

Territorium Online srl/GmbH
Via Buozzi/Buozzistraße 12 - I 39100 Bolzano/Bozen
email: andreas.albarello at territoriumonline.com
web:   www.territoriumonline.com
--------------------------------------------------------------------



More information about the MapServer-users mailing list