Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with OGC filter.

My layer in OpenLayers has this filter:

filter: new OpenLayers.Filter.Comparison({ 
            type: OpenLayers.Filter.Comparison.BETWEEN, 
            property: "datetime", 
            lowerBoundary: "2013-01-10T12:11:50.501Z", 
            upperBoundary: "2013-01-10T12:11:55.501Z" 

and the post to server is:

<ogc:Filter xmlns:ogc="">

but the reply is:

<wfs:FeatureCollection numberOfFeatures="0" timeStamp="2013-01-10T12:11:15.100Z" xsi:schemaLocation="AidAssistant" xmlns:ogc="" xmlns:tiger="" xmlns:cite="" xmlns:nurc="" xmlns:sde="" xmlns:wfs="" xmlns:topp="" xmlns:it.geosolutions="" xmlns:xsi="" xmlns:AidAssistant="AidAssistant" xmlns:sf="" xmlns:ows="" xmlns:gml="" xmlns:xlink="">

I tried to use this filter:

filter: new OpenLayers.Filter.Logical({ 
        type: OpenLayers.Filter.Logical.AND, 
        filters: [ 
                new OpenLayers.Filter.Comparison({ 
                    type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO, 
                    property: "datetime", 
                    value: 2013-01-10T12:25:40.612Z 
                new OpenLayers.Filter.Comparison({ 
                   type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO, 
                   property: "datetime", 
                  value: 2013-01-10T12:25:50.612Z 

and the post is:

<ogc:Filter xmlns:ogc="">

and the reply is the same, 0 features.

There are features in my layer, indeed if I do this request:

I receive a lot of features.

But if I try this:

I receive 0 features.

Sorry for the long post :(

Can someone help me?


Update: Maybe I have found the error. Geoserver to do this query on the DB:

SELECT "node_id","datetime","geom".STAsBinary() as "geom"
  FROM "v_dati_sensori_geom_BNU1" WHERE  "datetime" BETWEEN '2013-01-3 16:45:53.000' AND '2013-01-10 16:45:58.000'

but this does not work because the right query on SQL SERVER is:

SELECT "node_id","datetime","geom".STAsBinary() as "geom"
  FROM "v_dati_sensori_geom_BNU1" WHERE  "datetime" 
  BETWEEN convert(datetime, '2013-01-3 16:45:53.000', 120)  AND convert(datetime, '2013-01-10 16:45:58.000', 120)

Workaround for this problem?

share|improve this question

You should use raw MSSQL format of timedates in the filter. You can use solution from or from documentation


    SELECT "node_id","datetime","geom".STAsBinary() as "geom"
      FROM "v_dati_sensori_geom_BNU1" WHERE  "datetime" 
      BETWEEN convert(datetime, '2013-01-3 16:45:53.000', 30)  
      AND convert(datetime,'2013-01-10 16:45:58.000', 30)

work correctly? '30' style is interpreted as default styly '0' (see documetation


share|improve this answer
My mistake, was: convert (datetime, '2013-01-3 16:45:53.000', 120) – pask23 Jan 11 '13 at 8:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.