I'm using an NSPredicate
with a couple of <=
constructs to fetch objects from a Core Data store with a startDate
attribute between 2 dates but I'm getting 0 objects fetched.
Here's my NSPredicate:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"( ( %@ <= %K ) && ( %K <= %@ ) )", fromDate, @"startTime", @"startTime", toDate];
Here's the console output:
predicate: CAST(336261600.000000, "NSDate") <= startTime AND startTime <= CAST(339285599.000000, "NSDate")
[sectionInfo numberOfObjects]: 0
Here are the dates that are in Core Data (the Attribute Type is set to Date):
startTime
---------
337249800
337309200
337318200
fromDate
and toDate
are both NSDate
objects. I've tried substituting these with distantPast
and distantFuture
to make completely sure than my Core Data startTime
attributes are within the date range and I still get 0 object fetched.
I have no idea why 0 objects are returned. Can anyone see where I'm going wrong?