CBR Computed Fields do not store any value in DB

I wanted to compute some fields depending on other fields but the CBR Computed Field does not store any value in the database. When computing the same value with the standard Computed Field, the values are all calculated correctly and stored in the DB.
1 answer

Insert the following Code in the computed code field

$field_cbr_start = field_get_items($entity_type, $entity, "field_project_start");
if($field_cbr_start != NULL)
{
$start_date = $field_cbr_start[0]["value"];
$start = strtotime($start_date);
$field_cbr_end = field_get_items($entity_type, $entity, "field_project_end");
if($field_cbr_end != NULL)
{
$end_date = $field_cbr_end[0]["value"];
$end = strtotime($end_date);
$duration_month=($end-$start)/2592000;
if(isset($end)&&isset($start)) {
$entity_field[0]['value'] = $duration_month;
}
else $entity_field[0]['value'] = NULL;
}
else $entity_field[0]['value'] = NULL;
}
else $entity_field[0]['value'] = NULL;