title: Group by weekdays with Core Data
body: <p>In my Core Data Model i've got an entity that has a date attribute and as the title suggests, i'd like to group this entity by (week)days.</p>
  
  <p>The problem is, the dates are stored more or less as timestamps and i don't know how to create a predicate that is capable of grouping/filtering my entities approprioately.</p>
  
  <p>I've figured out that i will probably have to do a fetch for each day, so created following method.
  The code were i need help with is right in the middle of it.</p>
  
  <pre><code>- (NSFetchedResultsController *)fetchedResultsController:(NSDate *)day  {
  if(fetchedResultsController != nil)
      return fetchedResultsController;
  
  // Create and Configure Request
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:managedObjectContext];
  [request setEntity:entity];
  
  // Predicate
  // pseudo code where i'm clueless is marked by "&lt;" and "&gt;" - start
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"DateAttribute BETWEEN &lt;first second of day&gt; AND &lt;last second of day&gt;"];
  // or
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"&lt;dayofmonth-month-year of DateAttribute&gt; LIKE &lt;dayofmonth-month-year of day&gt;"];
  [request setPredicate:predicate];
  // pseudo code where i'm clueless is marked by "&lt;" and "&gt;" - end
  
  // Sort descriptors
  NSSortDescriptor *titleDescriptor = [[NSSortDescriptor alloc] initWithKey:sortDescriptorName ascending:YES];
  NSArray *sortDescriptors = [NSArray arrayWithObject:titleDescriptor];
  [request setSortDescriptors:sortDescriptors]; 
  
  // create and init fetchResultsController
  NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
  self.fetchedResultsController = aFetchedResultsController;
  fetchedResultsController.delegate = self;
  
  //Memory
  [request release];
  [titleDescriptor release];
  [aFetchedResultsController release];
  
  return fetchedResultsController;
  </code></pre>
  
  <p>}</p>
  
  <p>I'd really appreciate any help. Thanks</p>