1. What is the issue? Please be detailed.
I have introduced the formulas to calculate the age from the SA ID number:
type name Label
barcode id_barcode Please scan the ID Barcode of head of the household
type name calculation
calculate birth_year if(substr(${id_barcode}, 0, 2) > (format-date(today(), '%y')), concat('19', substr(${id_barcode}, 0, 2)), concat('20', substr(${id_barcode}, 0, 2)))
calculate birth_month substr(${id_barcode}, 2, 2)
calculate birth_day substr(${id_barcode}, 4, 2)
calculate birth_date concat(${birth_year}, '-', ${birth_month}, '-', ${birth_day})
calculate head_age int((today() - date(${birth_date})) div 365.25)
When testing the form, at the step when I'm supposed to capture the details of the household head, I get the following error:
Error evaluating field 'head_age' (/data/household_head[1]/head_age[1]):
The problem was located in Calculate expression for / data/ household_head/head_age
XPath evaluation: type mismatch
The value "20--" can't be converted to a date.
2. What steps can we take to reproduce this issue?
3. What have you tried to fix the issue?
4. Upload any forms or screenshots you can share publicly below.