Using runtime date fields as a query parameter

4452
1
01-29-2015 11:46 AM
MichaelDavis3
Occasional Contributor III

I was having trouble filtering data from a runtime geodatabase based on date fields (not using a time-aware database).  I finally figured it out:

https://geobits.azurewebsites.net/querying-esri-runtime-database-featuretable-with-datetime-field/

The quick-and-dirty version is that you need to do string comparisons of your date field and whatever NSDate variable you want to compare against, like this:

query.whereClause = [NSString stringWithFormat:@"strftime('%%Y-%%m-%%d %%H:%%M:%%S', DateTime) >= '%@'", [Utility returnStringFromDate:mapViewController.filterDate withDateFormat:@"yyyy-MM-dd 00:00:00 +0000"]];

[Utility returnStringFromDate: withDateFormat:] is just a wrapper for an NSDateFormatter and string conversion function.

-Mike

1 Reply
ForrestKaye
New Contributor III

I also have spent a lot of time trying to figure this out.  I haven't tried your solution yet but it looks like it should work.  Exactly what I was looking for. (working on the Android side through) If someone from ESRI is looking at this a sample with a date query would be helpful