I\'m trying to fetch from Core Data records that have a startTime between two dates.
Here\'s my code:
NSDate *today = [NSDate date];
NSDate *distantF
Perhaps try using AND instead of && (although your console output seems to show it converting correctly.
I just posted an example that works for me, note that my condition is flipped like so:
@"(%K >= %@) AND (%K <= %@)"
Here is the full example
According to the documentation, the BETWEEN
operator counts as an aggregate expression, and ...
Aggregate expressions are not supported by Core Data.
So yes, in order to work around this, you must use the >=
and <=
construction.
However, given that one of your dates is [NSDate distantFuture]
, you don't need the "less than" comparison at all. You should be able to do:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"startTime >= %@", [NSDate date]];