Calculate Age From External CSV

Dear Team,
I am trying to Calculate age from Date of Birth in External CSV.
Is it possible to do this.
Kindly Suggest.

Thanks.

Absolutely, calculating age from Date of Birth in an external CSV with ODK XLSForm is totally doable. Here's a quick rundown:

  1. Make sure your CSV has a Date of Birth (DOB) column.
  2. In your XLSForm, add a new question for the calculated age.
  3. Use ODK's date functions to do the math. For instance, you can use "today()" to get the current date and then figure out the age based on the DOB.
  4. Update your form logic accordingly.

Useful ODK documentation links
Building selects from CSV files

Date and time

Best of luck

1 Like

when i am trying calculation gives no response

I have pulled date of Birth from External. But when i am trying to calculate with Today() in XlS from it gives no response

Can you share the external CSV and xlsform files?

There are a lot of existing threads about this very subject, you should start with these as the problem has likely been solved unless the dates in your CSV are uniquely formatted and these approaches don't work.

2 Likes

REGISTRATION_2024_04_07_07_52_35_831234.csv (4.6 KB)
Monthly_Information (1).xlsx (24.1 KB)

Thanks for guide me but it is only dummy data not personal.

1 Like

To get age as number of months, try using this formula

12*(${Year1}-${Year2}) + ( ${Month1}-${Month2} )

Year1: Current Year
Month1: Current Month

Year2: DOB Year
Month2: DOB Month

Not working, if date of birth is 20/12/2023

Hi rakesh,

This formula will consider days also.
if (${Day1} < ${Day2},
12*(${Year1}-${Year2}) + (${Month1}-${Month2} - 1) + (${Day1} - ${Day2})/30,
12*(${Year1}-${Year2}) + (${Month1}-${Month2}) + (${Day1} - ${Day2})/30)