title: Core data fetch predicate for NSDate
body: <p>I have entity with two NSDate properties:</p>
  
  <pre><code>@property NSDate *startTime;
  @property NSDate *endTime;
  </code></pre>
  
  <p>I use it for creating the point events and the duration events. So, for the point events <code>endTime</code> can be equal to nil.</p>
  
  <p>And i want to fetch all entities with restriction: startTime >= minDate &amp;&amp; endTime &lt;= maxDate</p>
  
  <p>But NSPredicate like: </p>
  
  <pre><code>NSDate *startTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"firstBound"];
  NSDate *endTime = [[NSUserDefaults standardUserDefaults] objectForKey:@"secondBound"];
  [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"(startTime &gt;= %@) AND ((endTime &lt;= %@) OR (endTime == nil))",startTime,endTime]];
  </code></pre>
  
  <p>Does not work correctly. I`ll explain. If all the events stored in the database are in the range 2000-2010 year, and I'm doing a fetch with minDate = 1900, maxDate = 1950 EVERYTHING the point events from the database fit this predicate, because they endTime field is nil, and the field startTime clearly more than minDate.</p>
  
  <p>Any idea how to handle this? Do not be limited by the NSPredicate. I will approach any decision.</p>