Select to view content in your preferred language

Feature layer WHERE clause syntax

4857
6
02-02-2011 10:37 AM
DonFreeman
Emerging Contributor
How do you write a WHERE clause in a feature layer when you want to do a string compare? Something like this:
<esri:FeatureLayer ID="AllAvailableFeatureLayer" 
      Url="http://gismaps.pagnet.org/ArcGIS/rest/services/testprojectALLBikeCounts/MapServer/0"
      MouseLeftButtonUp="AllAvailableFeatureLayer_MouseLeftButtonUp"
      SelectionColor="Yellow"
      OutFields="*"
      Where="VolunteerAM='Available' and VolunteerPM<>'Available'"
      />


Thanks
0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
At first glance, your code looks good except if your field is a coded domain. In this case you have to use the code value for 'Available'.
0 Kudos
DonFreeman
Emerging Contributor
At first glance, your code looks good except if your field is a coded domain. In this case you have to use the code value for 'Available'.


Thanks dbroux. I found this works.

Where="VolunteerAM = 'Available' and VolunteerPM != 'Available'"
0 Kudos
HamidMokdes
Occasional Contributor
How can we compare against Date Fields.
It appears that injecting date comparison statement will depends on the back end Database you're using.

In my Feature Service I have a column named datetime and I want to be able to filter on that column, so I'm using expressions like these but none of them works:
datetime > '2011-01-01'
datetime > '2011/01/01'
datetime > 2011-01-01
datetime > 2011/01/01
I tried even: datetime > to_date(2011-01-01,'YYYY-MM-DD') [Our data base is oracle]

Any Idea how to make such comparisons [and is there a way to not depend for back end DB for this statement, or at least know know which system we run against from the service metadata ?]
0 Kudos
JenniferNery
Esri Regular Contributor
0 Kudos
AnastasiaAourik
Emerging Contributor
I am consuming a secure map service from a vender that has attribute ENT_LST_DT as  esriFieldTypeDate
When I query objectid 0,1,2,3,4 for ENT_LST_DT I see the values shown as :
ENT_LST_DT: 486345600000
API_NUM: 04111204350000

ENT_LST_DT: 817689600000
API_NUM: 04237024880000

ENT_LST_DT: 641433600000
API_NUM: 04237026310000

ENT_LST_DT: 1333152000000
API_NUM: 04237204030000

On my own map services and the map service you mention in this post, the date is returned as
datetime: 2012/05/23 15:17:45 UTC

----------------------------------------------
So I was wondering why would a date display as that weird number, and more importantly, how do I add a whereclause on this featurelayer.
Your suggested syntax does not work in this case.

I get Unable to complete operation.
Unable to complete Query operation.

{Do I need to ask the vender about this? Or do you recognise this internal format of an esriFieldTypeDate)

ps. The only difference I see in the rest endpoint is that their date field is shown as
ENT_LST_DT (Type: esriFieldTypeDate, Alias: ENT_LST_DT)

whereas the earthquake and all my own date fields on my map services has LENGTH : 36
SPUD_DATE (Type: esriFieldTypeDate, Alias: SPUD_DATE, Length: 36 )

Can you assist?
0 Kudos
JenniferNery
Esri Regular Contributor
It seems that your date field is a number that represents the number of milliseconds since epoch (January 1, 1970) in UTC, so your Where clause has to be in the same format.  You can test if this is the case, by using some Epoch converter: http://www.epochconverter.com/. Here are some guidelines for writing your Where clause: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s500000033000000.htm
0 Kudos