How to start date and end date comparing in iphone sdk code?
Example:->
if ([nowdate compare:raceStartDate] == NSOrderedDescending && [nowdate compare:raceEndDate] == NSOrderedAscending)
{
}
How to start date and end date comparing in iphone sdk code?
Example:->
if ([nowdate compare:raceStartDate] == NSOrderedDescending && [nowdate compare:raceEndDate] == NSOrderedAscending)
{
}
NSDate *date1;
NSDate *date2;
if ([date1 compare:date2] == NSOrderedDescending) {
NSLog(@"date1 is later than date2");
} else if ([date1 compare:date2] == NSOrderedAscending) {
NSLog(@"date1 is earlier than date2");
} else {
NSLog(@"dates are the same");
}
Try this
- (BOOL)date:(NSDate*)nowdate isBetweenDate:(NSDate*)raceStartDate andDate:(NSDate*)raceEndDate
{
if ([nowdate compare:raceStartDate] == NSOrderedAscending)
return NO;
if ([nowdate compare:raceEndDate] == NSOrderedDescending)
return NO;
return YES;
}