Date Difference calculation Not Working In My Form

Hell Community,

I am developing a simple form to help me understand odk-x survey form development. The challenge I have now is calculation function for getting the difference between two dates is not returning anything. I want to return the difference between the dates in weeks. There is no error in the form and I expected the calculation to work.

I have looked at several example forms with calculations and I think I did it the right way. Could someone please look at the attached form and troubleshoot for me.

Below is the screenshot of what I am getting.

image
screeningForm1.xlsx (12.9 KB)

Hi @mmukhanya! One key issue is you need scr_lmp_GA defined in your model statement (with an integer or decimal type depending on what you’re calculating).

One other thing may be to make sure the assign is on a different page after you enter the data - it may not evaluate until you press next.

1 Like

Dear @elmps2018, thank you so much for the immediate response.

I have implemented the two suggestions but the problem still exists. I want to return the result in decimal type. Do you have any sample form that calculates the difference between two dates and returns the result in weeks? If you do then kindly share with me.

Kindly find the attached updated form according to your recommendations.
screeningForm1.xlsx (13.0 KB)

Hi @mmukhanya! I don’t have any particular formulas in weeks, but did want to suggest you check first whether the dates are being recorded correctly in tables for the two inputs, in case that is part of the issue. If the dates are recorded correctly, I’d then suggest you do some trial-and-error with the calculates formula. For instance, first set the formula to just assign the new variable to be one of the existing ones, and see if that works. Then do the operations you want on the variable to calculate the new variable one by one. That may help you find if there’s a bug in the calculates syntax.

Hi @elmps2018, it finally worked. Your first suggestion of including the assigned field to the model is what has worked magic for me. I realized I did not include ‘()’ while calling the calculation function in my survey.

Thank you so much.

3 Likes

14 posts were split to a new topic: Problem with warning note and skips

One more help please, how can i deal with the repeat count? suppose i have the number of members, then i need to fill their information of all members i have.

it works fine now, thank you for the help, i really appreciate.