calculating the duration worked out using the computed field
I have requirement to
1.sum up all the durations in a work experience field collection in resume,
help me please pl.
2. Calculate the duration from the oldest start date to Date Now()
have look at screen shot
help please

CommentFileSizeAuthor
resume.png62.95 KBkaizerking
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

astanley86’s picture

Did you figure out how to do this? I am trying to do the exact same thing!

Thanks.

kaizerking’s picture

there is no existing module, and you need to develop a custom module for this, it is really tough job i didn't use computed field module, this module doesn't work with fields 'attached' to field collection fields

astanley86’s picture

Can you share your custom module? I'm discovering it is more complicated that I'm capable of doing with my limited knowledge of programming.

jlsevillano’s picture

Did you resolve the problem? I have the same problem :(

david.qdoscc’s picture

Issue summary: View changes

This should work in a computed field to sum field collection values:

$sum = 0;
$wrapper = entity_metadata_wrapper($entity_type, $entity);
foreach($wrapper->field_YOURFIELDCOLLECTION as $collection) {
$sum += $collection->field_YOURSUBFIELD->value();
}
$entity_field[0]['value'] = $sum;

James Feng’s picture

qdoscc's code is good,Thank you。