Calculate time between 2 dates

Dear all,

Is there a way to 'calculate' the time between 2 dates?
I want to know how long ago the participant was diagnosed with an illness.
So one question will be "When were you diagnosed?"
Another question will be "What is today's data?" [though I know this can be caught as metadata too]
And then I want ODK to calculate the time between these two.

Many thanks in advance!
Johnny Evans

Calculating difference in days is possible. Use a calculate type question with the following expression:
round(decimal-date-time(today()) - decimal-date-time(${date_diagnosed}))

Calculating the number of months or years is more complicated, see this post for details:

And here's a post that explores calculating age:

1 Like