Reputation: 196
In my application I am using CoreData
. Some date values are stored in coredata as NSString
.
In my Interface Builder
i have a textfield.When i enter a date on my textfield This date will compare dates in saved in coredata.
What will be the solution.I just goes through this way Example It Not be worked on my project because i want to convert string to date on my NSPredicate
method.
My code is
NSPredicate *p3 = [NSPredicate predicateWithFormat:@"acc_date >= %@ AND acc_date<=%@", theDate, date1];
Here acc_date
is dates from Database that is stored as string theDate and date1 are my inputs
Upvotes: 1
Views: 1068
Reputation: 46718
If you continue to store the dates as strings then you cannot do any kind of comparison like you are attempting.
If you store them as actual NSDate
instances then your comparison will work. The issue is not with your predicate but with how you are storing your data in Core Data.
I would suggest migrating your database, either with a heavy migration or with a manual migration. If your data is disposable then I would change the fields and reset your database to use NSDate
instances.
Upvotes: 2