I have a core data backed app for which I am implementing a searchBar.
Search scope is on a couple of string fields and date fields. The string searches work fine but the date searches are not returning what I would expect.
If I use "==" in my Predicate and try to search on an exact date, nothing gets returned.
If I use ">=" then I do get my date however I also get everything later than my date which I don't really want.
I would like to search on exact dates. I suspect this issue has something to do with the date formatting of the core data date field vs. my searchText formatting.
The output from "moveInDateFromSearchText" looks like this:
2009-09-19 07:00:00 +0000
Code:
// Search on moveOutDate
}else if ([scope isEqualToString:@"Out"]){
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy"];
NSDate *moveOutDateFromSearchText = [dateFormatter dateFromString: searchText];
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"moveOutDate >= %@", moveOutDateFromSearchText];
self.filteredListContent = [[[self fetchedResultsController] fetchedObjects] filteredArrayUsingPredicate:predicate];
NSLog(@"moveOutDateFromSearchText = %@",moveOutDateFromSearchText);
// Search All
}else {
// etc.....
{
Thanks in advance for any help.