2

I am having array of dates and i need to fetch only those dates which comes between two differnt dates (StartDate and EndDate)..

can any one help me out in solving this... thanks in advance

Vinay
  • 171
  • 1
  • 7

2 Answers2

4

Assuming you have startDate and endDate instances of type NSDate you can:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF > %@) AND (SELF < %@)", startDate, endDate];
NSArray *result = [arrayWithDates filteredArrayUsingPredicate:predicate];
graver
  • 15,183
  • 4
  • 46
  • 62
0

Check out filterWithPredicate, it allows you to create a filter rule to apply against all elements in the array.

MystikSpiral
  • 5,018
  • 27
  • 22
  • hi MystikSpiral Thanks for your quick reply. but how can i pass two dates so that it will get all date which comes between those two dates.. and even more start and end dates are taken from same array of dates only – Vinay Apr 18 '12 at 20:35