Note that there are some explanatory texts on larger screens.

plurals
  1. POgroup by date (yyyy/MM/dd) with NSFetchRequest
    text
    copied!<p>i have to count and group on more that 3 properties. i'm pulling my hair while grouping and counting on field with date (yyyy/mm/dd HH:mm:ss) i want to group by year - month - day and ignore the time. but i still need the time for detail view. time zone plays a big role here. so i just save it in utc format.</p> <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"logs" inManagedObjectContext:context; NSAttributeDescription* att3 = [entity.attributesByName objectForKey:@"savedDate"]; NSExpression *keyPathExpression3 = [NSExpression expressionForKeyPath: @"savedDate"]; NSExpression *countExpression3 = [NSExpression expressionForFunction: @"count:" arguments: [NSArray arrayWithObject:keyPathExpression3]]; NSExpressionDescription *att3Description = [[NSExpressionDescription alloc] init]; [expressionDescription3 setName: @"countSavedDate"]; [expressionDescription3 setExpression: countExpression3]; [expressionDescription3 setExpressionResultType: NSInteger32AttributeType]; ... [fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:att1, att1Description, att2, att2Description, att3, att3Description, att4Description, att4, nil]]; [fetchRequest setPropertiesToGroupBy:[NSArray arrayWithObjects:att1, att2, att2, att3, nil]]; [fetchRequest setResultType:NSDictionaryResultType]; </code></pre> <p>how can i can group by date (yyyy/MM/dd)? and be ok for converting to UTC?</p> <p>thanks in advance</p> <p>ps: group by on a transient property doesnt work and cant be fetched.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload