Hi again folks,

I am trying to calculate a sum of work-years based on database entries. In the end, for each employee, there should be displayed his total work-time in the department based on one or more employments.

basically, I tried it with THIS:

```
class WorkYearsManager(models.Manager):
def with_work_years(self):
today = datetime.date.today()
return self.annotate(
past_years=ExpressionWrapper(
(F('duty_end') - F('duty_begin')), output_field=fields.FloatField()
)/86400/365.2425/1000000*F('percent')/100
).annotate(
ongoing_years=ExpressionWrapper(
(today - F('duty_begin')), output_field=fields.FloatField()
)/86400/365.2425/1000000*F('percent')/100
)
def total_work_years(self, employee):
return self.with_work_years().filter(employee=employee).aggregate(
total_work_years=Sum('past_years') + Sum('ongoing_years')
)['total_work_years']
```

but of course, here will be calculatet the `duty_end`

- `duty_begin`

duration for EACH employment AND the `today`

- `duty_begin`

duration also for EACH employmentâ€¦which leads to a way too large sum.

So, i need to restrict the `ongoing_years`

calculation on the actual employment and the `past_years`

calculation to all former employmentsâ€¦