I am storing a date attribute in Core Data using the datePicker on the iPhone. I want to then compare the date that matches a certain date using == but I can't get it to work. The greater than and less than seem to working fine though.
At first I was storing the date directly from the datePicker which also included the time information. So I used the NSCalendar to strip of the time and just store the date.
Similarly I take the rhs of the predicate and run it through NSCalendar to extract just the date and do the comparison and I still can't get the == to work.
Tried doing a NSLog of the date being stored in CoreData and the date being compared and they look exactly the same 2010-06-19 00:00:00 -7:00
Any pointers will be appreciated.
EDIT: I am trying to do the comparison in CoreData using the NSEqualToPredicateOperatorType passed into the
+ (NSPredicate *)predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs modifier:(NSComparisonPredicateModifier)modifier type:(NSPredicateOperatorType)type options:(NSUInteger)options
with the lhs being the keypath to entity.dateAttribute and rhs being [NSExpression expressionForConstantValue:myDate];
PS: I had the above code and then realized that myDate consisted of a time component so I modified the above code to extract only the day, month and year and use it to send it to NSExpression.
Similarly while saving the date, I made sure that I am extracting only the date, month and year and passing it to CoreDate effectively making the time 00:00:00 (I hope!)