Select to view content in your preferred language

how to  set the queryfilter.where with date  type

497
2
11-02-2010 08:42 PM
yanli
by
Emerging Contributor
i  want to search feature by date?code like this
 string qstr = "??????????='" + System.DateTime.Today.ToShortDateString()+ "'";
ESRI.ArcGIS.Mobile.QueryFilter qf = new ESRI.ArcGIS.Mobile.QueryFilter(qstr, true);
   FeatureDataTable fdtabel = featureLayer.GetDataTable(qf, null);
    dataGridView1.DataSource = fdtabel;



error:The 'where clause' is invalid.


whre's wrong  ?anyone can help me?
0 Kudos
2 Replies
AkhilParujanwala
Regular Contributor
Have a look at my thread, there's a solution posted:
http://forums.arcgis.com/threads/13983-A-Simple-Query-of-a-FeatureClass-%28Help-Please%29

The first thing I see is you where clause may not be correct.

1) have messagebox pop up and show you your querystring (qstr).

2) The result from your query string should be
修�?��?��?� = 'Oct. 10, 2010'
This is just an example.

But if you need to see those apostrophe around the value (single quotes).

If you get a result like this:
修�?��?��?� = Oct. 10, 2010
or
修�?��?��?� = "Oct. 10, 2010"
You will get an error.

My code that I used is to solve this is:
string whereClause = "UserID = " + "'" + user + "'";

As you can see wrapped around user there is, quotation marks (double quotes), apostrophe (single quotes), quotation marks (double quotes) then a plus sign and then the variable (in your case Date) and then the rest is the same.

Let me know if this helps.
0 Kudos
yanli
by
Emerging Contributor
HI,AkhilP
i get the result from my query string
like this  修�?��?��?� = 'Oct. 10, 2010'
it is still error

then i  find in  the 9.2 help
i write query string  like this "  修�?��?��?� =date  '2010-11-03'  "

it's correct!!!
thank you all the same
0 Kudos