title: NSPredicate compare string less than other string
body: <p>EDIT: Ignore this question. I was not looking at my test-data properly. My code below works.
  But there are some good answers to look at. Thanks!</p>
  
  <p>For convenience we store all our data as strings in core data. Now I want to fetch all objects of an entity that has a timestamp older than a specified timestamp (oldDate). That means I want to do a compare with NSPredicate so the NSFetchRequest returns objects that has a timestamp less than the specified timestamp. The following obviously does not work but it is the best I have come up with this far.</p>
  
  <pre><code>- (void)deleteRecordsOlderThan:(NSString*)oldDate {
      NSError *error = nil;   
      NSFetchRequest *request =[[NSFetchRequest alloc] init];
      [request setEntity:[NSEntityDescription entityForName:tableName inManagedObjectContext:context]];
      [request setIncludesPropertyValues:NO];
      [request setIncludesPendingChanges:YES];
      NSPredicate *predicate = [NSPredicate predicateWithFormat:@"timestamp &lt; %@)",oldDate];
      NSLog(@"Predicate: %@",predicate);
      [request setPredicate:predicate];
  
      NSArray *filteredObjects = [context executeFetchRequest:request error:&amp;error];
      [request release];
      if (error) {
          NSLog(@"Error fetching objects for deletion: %@", [error description]);
          return;
      }
      NSLog(@"Number of old objects to delete:%d",filteredObjects.count);
      for (NSManagedObject * nsObject in filteredObjects) {
          [context deleteObject:nsObject];
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I hope you understand what I mean. It's a bit hard to explain.</p>