Hi, i use core data in my iphone app, but in some case i use sqlite to access to data and ia have a problem with NSDate.
NSDate *now = [NSDate date];
NSCalendar *calender = [NSCalendar currentCalendar];;
NSDateComponents *comp = [calender components:NSYearCalendarUnit fromDate:now];
[comp setDay:1];
[comp setMonth:1];
NSDate *yearAgo = [calender dateFromComponents:comp];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date > %@",yearAgo];
This code works and select records from the start of year, but if i use sqlite raw query
NSDate *current=[NSDate date];
NSDateComponents *comps = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit |NSYearCalendarUnit) fromDate:current];
[comps setDay:1];
[comps setMonth:1];
NSDate *yearDate = [gregorian dateFromComponents:comps];
[where appendFormat:@"zdate > '%@' ",yearDate];
I have a problem, wrong date determined by the records, Records that in core date has date like 2008-01-01 in sqlite have dates like 1977 year. How to fix it? May be I was wrong to use NSDate in the query?