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.
I think this open issue is related to what you are trying to do.
It seems if you try and convert the string fetched through a pulldata() function into a date, the XLSForm will not validate. And to calculate the number of days you will need to be use decimal-date-time() to convert your string. See this example:
Dates are tricky.
One person did a workaround of the javarosa issue by storing the date as a number in the csv (a number that is the same value that using decimal-date-time() on the da…
Alas I'm using Kobotoolbox and it doesn't allow me to deploy.
[image]
I even tried doing format-date(string(pulldata(...))) but it doesn't work. Any other ideas?
1. What is the problem? Be very detailed.
We are working on a project which includes repeated anthropometric measures of infants across multiple time periods. We are currently developing a draft version of the form which will allow users to record these measurements. At our company we have developed a data platform system that can allow us to work with ODK forms using essentially a case management system. Therefore we will have CSV files providing information about the children and mothers for …
how to calculate age in months, days and years
I need your help I am a beginner xlsform
Hi again,
I use ODK and a I have a field date with the birthdate, and the ideai is a calculate the age, I use this formula:
format-date(today(), ‘%Y’) - format-date(${Birthdate}, ‘%Y’)
And it work, but I need to use all the date, I mean calculate the age with the year, the month and the day.
Can someone help me, please.
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:
2 Likes