I want to print the inbetween dates between 2 given dates .
e.g if fromDate=12/10/2014
and toDate=15/10/2014
then I want this,
12/10/2014
13/10/2014
14/10/2014
15/10/2014.
Can anyone guide me?
I want to print the inbetween dates between 2 given dates .
e.g if fromDate=12/10/2014
and toDate=15/10/2014
then I want this,
12/10/2014
13/10/2014
14/10/2014
15/10/2014.
Can anyone guide me?
Try this
//datemin= fromdate , datemax=todate
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
NSDateComponents *days = [[NSDateComponents alloc] init];
NSInteger dayCount = 0;
while ( TRUE ) {
[days setDay: ++dayCount];
NSDate *date = [gregorianCalendar dateByAddingComponents: days toDate: datemin options: 0];
if ( [date compare: dateMax] == NSOrderedDescending )
break;
NSLog(@"%@",date);
// Do something with date like add it to an array, etc.
}