I have a text field to collect a date of birth in mm-dd-yyyy. I then have a series of calculations to convert it to yyyy-mm-dd and turn it into a date field whereby I can then calculate a persons age. The age makes subsequent questions relevant or not (ie. is the person a minor or not). This works in my original form.
I created a new form and copy and pasted that section into the new form for the same purpose. The new form now gives me an error message:
Below is the sample of the xls form with the dob/age calculations:
I initially did the 'paste only values' and I've tried deleting the cells and then rewriting from scratch, but both had no effect. I've checked the sheet for any connections and there are none. In the original form, the dob/age calculations are within a repeat and are not in the new form, but I don't see how that would affect this.
Help!
RyanE
Hi Ryan,
It looks like this is a type mismatch error, caused by running an expression on a text field or using an answer from a previous question that is text, but trying to run a date or numeric expression on it. Calculate questions by default are text question, however if you set the bind::type, and/or bind::esri:fieldtype to the expected correct field type, the expression should work as expected.
If you are still having issues, can you please share your xlsx file.
Regards,
Phil.
When I removed the pt_dobdate row and then changed the types in the pt_dobstring row (bind::type and bind::esri:fieldtype to esriFieldTypeDate and dateTime respectively) it worked!
Thanks for the help,
RyanE
text | pt_dob | DATE OF BIRTH: | mm-dd-yyyy | 10 | 99-99-9999 | ||||||
calculate | pt_month | month | substr(${pt_dob},0,2) | null | |||||||
calculate | pt_day | day | substr(${pt_dob},3,5) | null | |||||||
calculate | pt_year | year | substr(${pt_dob},6,10) | null | |||||||
calculate | pt_dobstring | dobstring | concat(${pt_year},'-',${pt_month},'-',${pt_day},'T00:00:00-07:00') | esriFieldTypeDate | dateTime | ||||||
note | pt_age | AGE: | if(string-length(${pt_dob})=0,null,int((today()-${pt_dobstring})div(1000*24*60*60*365.25))) |