Date Calculation: how to increment a date by exactly 1 month

This is due to a bug in Validate. I'll try to post a new form with a workaround. In the mean time you can convert your existing form using XLSForm Offline, if you disable the 'ODK Validate' option.

OK, try this one: :pray:

addmonth_v3.xls (20 KB)

1 Like

thank you so much! that was immensely helpful, and i've learned a lot about ODK date calculations. I had no idea you could use the coalesce function in ODK too.

1 Like

YW. Sorry it took so many iterations to get finally right :slight_smile:

coalesce() is one of the more obscure/esoteric XPath functions you normally don't run across, but it occasionally has its uses (like this workaround). More typically you might use it to, say, convert null responses to 0 when adding up totals; eg

${a} + ${b} + ${c}

If some of the questions are optional (ie null value) then the above calculation wouldn't work (you'd get "NaN"). Instead you would write

coalesce(${a},0) + coalesce(${b},0) + coalesce(${c},0)