Has anyone had success applying a definition expression on a FeatureLayer based on a date field in the Runtime SDK? I am using the Android SDK and have a local geodatabase created via a sync task. I have a FeatureLayer that contains a Date field, and I want to apply a definition expression to only show features between a specific date range. Definition expressions based on other fields are working fine. I am assuming the problem is the formatting of the Where statement. I have tried:
DATE > Datetime('2015-9-24 00:00:00')
DATE > date '2015-9-24 00:00:00'
DATE > '1443128160724'
DATE > date '2015-9-24 00:00:00'
Here is a link to setDefinitionExpression
FeatureLayer | ArcGIS Android 10.2.8 API
Thanks in advance for any suggestions
Solved! Go to Solution.
Hey Kerry Halligan,
I did some research of this on my end and found that this query seemed to work best for me. The date field in my table is SuperDate and then I compared it to what we would expect the date format to be:
qp.setWhere("date(SuperDate) > date('2046-05-05')");
This would follow the format of how SQLite tables query for date.
More information on how to format a Date query against a SQLite database can be found here:
SQLite Query Language: Date And Time Functions
Does this help?
EDIT: You may also want to move this discussion to the Android Runtime SDK section of the site. I am not sure on how to do this but maybe power user, Dan Patterson, remembers how to.
Right below the magnifying glass is an option called "Actions".
If you click that you should see an option to move and from there you can move it to the Runtime SDK for Android section of GeoNet.
Hey Kerry Halligan,
I did some research of this on my end and found that this query seemed to work best for me. The date field in my table is SuperDate and then I compared it to what we would expect the date format to be:
qp.setWhere("date(SuperDate) > date('2046-05-05')");
This would follow the format of how SQLite tables query for date.
More information on how to format a Date query against a SQLite database can be found here:
SQLite Query Language: Date And Time Functions
Does this help?
EDIT: You may also want to move this discussion to the Android Runtime SDK section of the site. I am not sure on how to do this but maybe power user, Dan Patterson, remembers how to.
Right below the magnifying glass is an option called "Actions".
If you click that you should see an option to move and from there you can move it to the Runtime SDK for Android section of GeoNet.
That did it! Thanks for your help on this issue. As a note for other users, don't forget to pad month and day to 2 characters. It would be great to see this example added to the Runtime SDK online documentation so that other users have a working example of date queries for FeatureLayer.setDefinitionExpression. Thanks!