Date that i am receiving from internet is of the format like:
"2014-12-01T20:00:00Z"
i am Storing date with this format in core data..Attribute type is also "Nsdate" type..
- (NSDateFormatter *)dateFormate
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy'-'dd'-'MM'T'HH':'mm':'ssZZZ"];
}
Getting start time of [NSDate Date] by using
- (NSDate *)cc_dateByMovingToBeginningOfDay
{
unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents* parts = [[NSCalendar currentCalendar] components:flags fromDate:self];
[parts setHour:0];
[parts setMinute:0];
[parts setSecond:0];
return [[NSCalendar currentCalendar] dateFromComponents:parts];
}
and end time of [NSDate Date] by using:
- (NSDate *)cc_dateByMovingToEndOfDay
{
unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents* parts = [[NSCalendar currentCalendar] components:flags fromDate:self];
[parts setHour:23];
[parts setMinute:59];
[parts setSecond:59];
return [[NSCalendar currentCalendar] dateFromComponents:parts];
}
and fetching with this one:
- (void)ObjectsFrom:(NSDate *)fromDate to:(NSDate *)toDate {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"((due_at > %@) AND (due_at < %@))",fromDate, toDate];
}
But record is always zero.as i know that in my today date i have multiple records in data base..i dont know why this happens..
i have also used NSComparisonResult for dates But no record is Between date.
SO please help me out in this..