Using preceding DATE-TIME question's response to constraint a question

I would like to use response to a given question as a constraint value with comparison operators for restricting the response to subsequent question.

eg
Q1: start_time
Q2: end_time

what should be the constraint syntax to ensure that the end time entered is not less than the Start time?

Hello,
did you try ${end_time} > ${start_time}?

1 Like

Yup,
It works. thank you very much.

1 Like

@Kal_Lam
Quite and interesting obeservation here.
The solution worked in the preview and also on desktop submission page. However, in the Android Kobocollect app, the constraint message shows up even though the entries are in conformance with the constraint.
Therefore, not able to submit filled forms. I have used ‘datetime’ type of questions.
Any idea what is the issue?

1 Like

Hello,
could you tell us, please, how you set the 2 variables?
It might be related to the time location. You could trace the 2 variables with a note, like label: End: ${end_time} Stat ${start_time}.

1 Like

Hello,

I have a similar issue trying to put constraint on a form about hunting. We want to know when the person went hunting, when he came back, and when he did catch an animal.

My constraints are (see also attached form)
on the date of return: . >= ${hunting_start}
on the catch date: . >= ${hunting_start} and . <= ${hunting_return}

The second constraint does not work when the start date is the same as the catch date.

Any idea why?

Thank you

Best

Diane

Test date and time.xls (19.5 KB) Test date and time.xls (19.5 KB)

Hi @dianedetoeuf,

Kindly please be informed that if you try this out in android Collect app (KoBoCollect or ODK Collect), it works as it should. But unfortunately it does not work as it should with Enketo.

Have reported this case with the developers. Will let you know back if there is any updates with it!

Have a great day!

Hi @dianedetoeuf,

Would you mind using the datetime instead of using date and time seperately as outlined in the image below (for catch as well):

It should solve your issue.

Data Entry screen as seen in Enketo:

Reference xlsform:
Test date and time.xls (28.5 KB)

Have a great day!

3 Likes

Hi Kal,

It works! Thank you so much for your time and solving this.

Have a great day too

Diane

3 Likes