Age calculation

Hi dear all.
I’d like to know how to calculate the age of a participant from his date of Birth with Kobo.
Need your support please.

try this:

calculation: age = round((decimal-date-time(today()) - decimal-date-time(${dob})) div 365)

Note, this isn’t 100% precise, because it assumes all years have 365 days, which isnt the case for any intervening leap years. So if the date-of-birth is within a few days to today, you could potentially end up a year off. If you need 100% accuracy you’ll have to correctly account for these additional leap year days, which would require a more complicated algorithm.

1 Like

Thanks somuch.
i tried but Don’t work. Do i need to set “today” and “dob” as questions? Could you explain all the process to me please?


I use (${today}-${fecha_nacimiento}) div 365.25
The decimal help me take into account the years where february has 29 days.

Today i define it in the beginning as a metadata: image

Hope it works for you

Can you check on the article on advance calculate which has the age provided as an example.

I have also created a sample form which you can access here

Hope it works for you


Yup, 365.25 is probably a better approximation to use (actually, 365.24 is even better). But again, please note this is still only an approximation - if you want to be 100% correct (ie in all cases) then you have to determine precisely how many leap years are between the two dates (now and DOB), which requires a far more complicated algorithm. For example, in any arbitrary 8 year interval - D/M/Y1 to D/M/Y2 - there could be 1,2 or 3 leap years, depending on the specific dates and years. For more than you ever wanted to know, see

Basically, if you are a perfectionist, any calculation involving 2 dates gets very ugly very quickly :wink:


Thanks, i’ll try and let you know.

Ahaha thanks for your answer!
As far as i need it i don’t need to overcomplicate it, just about threshold of age and i took a margin of a few days to be totally sure to not omit anyone. Anyway it’s interesting sharing tecnics thanks!