I would like get the difference between two dates in order to enable me calculate the ages of children in months. My assumption is that their mothers (who will be asked when the child was born) may not know or their ages in month but are aware on their date of birth. So I need a formula that would substract their date of birth from the current date Now() and display the result in months.
Kindly assist
Hello @rigs,
I've done something like this in the past for some child growth monitoring systems. Try it and test to see if it solves your question
You will need a variable with DOB. We will then get the date serial
that corresponds with it using conversion int(${DOB})
and we will lessen that from int(today())
and the result (in days
) will be devided by 30.4384064010668
-- very debatable, but that's about on average how many days they might be in a month for this calculations
Wrapping up, in the variable where you need the number of age in months, use the following in the Calculation column (int(today()) - int(${DOB})) div 30.438406010668
and if you need some rounding of the decimal places, use round((int(today()) - int(${DOB})) div 30.438406010668,2)
instead (2 dec places)
One technical tip, always make sure that tablet dates are set properly, and one quick way of being sure no off dates are used is to limit today() >= ${date_survey_started}
Hoping this helps,
Jules R