3

I can query a featureLayer in my javascript map to only show features meeting criteria for normal attributes (strings/integers), as below for example

featurelayer.setDefinitionExpression("status = 0"); // working fine

However i would like to query based on date field in my feature layer - (e.g. only display records newer than 01/01/2014)

in the service metadata the field is described as:

date_created ( type: esriFieldTypeDate , alias: DATE_CREATED , length: 36 )

I have looked through the the documentation, however i have seen no mention of how to do this kind of query, the closest thing mentioned is the setTimeDefinition, but this appears more related to making time-aware maps rather than performing a simple filter on a layer

1 Answer 1

4

You would set the expression as MYDATE >= date'1-16-2013' (date format may vary based on locale)

Example date range filter :

featurelayer.setDefinitionExpression("MYDATE >= date'1-16-2013' AND MYDATE < date'1/29/2015'")
1
  • thank you, this solved my issue! i did not know the the date'...' was necessary, but now it makes sense, cheers!
    – weaverk
    Feb 4, 2015 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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