Ercan
Ercan

Reputation: 2773

Core Data NSPredicate for date

In my model I have date attribute and I set it [NSDate date], but getting with predicate like

 NSPredicate *predicate = [NSPredicate predicateWithFormat:
                              @"date==%@ ,date]; 

returns notting. I know the problem is when I set [NSDate date] it stores also time and NSPredicate always return empty data. Is there any way to convert "date==%@" part to only look for date?

Upvotes: 7

Views: 7127

Answers (1)

cancerian
cancerian

Reputation: 942

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(date >= %@) AND (date <= %@)", startDate, endDate];

Upvotes: 20

Related Questions