select by attributes with wildcard, date field

5857
5
07-13-2011 08:39 AM
MikeWissner
New Contributor II
Hello all,

I have a date field that contains hundreds of unique values.  I need to select by year.  However my sql query: "Fieldname" = date '2009%' is invalid.

Also, for whatever reason my attributes are displayed in mm/dd/yyyy format, while in the select by attribute unique field box they are displayed as date 'yyyy-mm-dd'

I've tried a bunch of different sql combinations and nothing works.  Please help!

thanks much,
peace
0 Kudos
5 Replies
DarrenWiens2
MVP Honored Contributor
As far as I know, there is no way to use LIKE on a date field in ArcGIS (correct me if I'm wrong). You can use BETWEEN though. This example will return all dates in 2005 (actually you probably need to adjust the final time to get records from the last day). This works for me, you may have to adjust the date format.
"DateField" BETWEEN date '2005-01-01 00:00:00' and date '2005-12-31 00:00:00'
IbrahimMohammed_Ahmed
New Contributor III

thank you, works great. but what i need to do is to get the features that is not being visited between the current_date and a certain period of it, like for example : " where "features" between current_date  and 10 days ago ".. any suggestions ?

0 Kudos
DanPatterson_Retired
MVP Emeritus

posting a new question in a 5 year old thread probably isn't going to pique much interest unless you provide the syntax etc as was suggested in one of the responses

0 Kudos
MikeWissner
New Contributor II
Thanks dkwiens, that was a great idea.

However, I still couldn't get it to work.  Any other suggestions?
0 Kudos
DarrenWiens2
MVP Honored Contributor
It works for me, so my suggestion is to post your SQL statement and a subset of your data.
0 Kudos