title: iOS: Compare two less or equal NSDates
body: <p>I want to compare two dates and do something when one is less or equal than the other, I tried to do it this way:</p>
  
  <pre><code>if ([self.system.systemInbetriebnahme compare:date] == NSOrderedDescending)
          return nil;
  </code></pre>
  
  <p>But this removes the case when they are both equal is there a way to compare dates with <code>&gt;=</code> ?</p>
  
  <p>Thank you</p>
  
  <p><strong>More details:</strong>  I have a date taken from a double dimension array, and i have a date stored in core data(through date picker), and i go through a loop to compare the two dates with the rule that: Date in array must be greater or equal than input date stored in database.</p>
  
  <p><strong>Latest Edit:</strong></p>
  
  <ul>
  <li><p>I import a csv file which after parsing and formatting gives me two rows(one for number value and one for dates). Here I am interested in dates.</p></li>
  <li><p>I store all these in an array and save after checking consistency of the data in this function:</p>
  
  <pre><code>for (NSArray * row in array) {
  
  
   // Handle import if there are at least two rows
  
  
  if (row.count &gt; 1) {
  
              dispatch_sync(dispatch_get_main_queue(), ^{
                  // Try to import value,date formatted row
                  double value = [row[0] doubleValue];
                  NSDate * date = [dateFormatter dateFromString:row[1]];
                 //else {
  
                      // Try to import date,value row
  
                      if (date &amp;&amp; value != 0.0) {
                          [self addReading:value forDate:date];
                      }
  </code></pre></li>
  <li><p>In here i call the function <code>addreading</code> to check for errors for some rules and if everything is okey then i save the managedObject Context.</p>
  
  <pre><code> if ([installationdatum compare:date] != NSOrderedAscending)
                 { 
                 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
                   message:@"installation date is bigger than data"
                                                                    delegate: nil
                                                           cancelButtonTitle:@"OK"
                                                           otherButtonTitles:nil] 
  
                      [alert show];
                     return nil;
  
  
  
                 } else
                 {  //Do nothing
  
                 }
  </code></pre></li>
  <li><p>One rule for me is to get the first row element in the array and compare its date with an input stored already in the database which is the <code>self.system.systemInbetriebnahme</code></p></li>
  <li><p>After all this I list all the resulting array in a tableview, though value matching <code>NSOrderedSame</code> is never shown when it is equal to <code>self.system.systemInbetriebnahme</code></p></li>
  </ul>