Create constraint for time (8 AM to 2 PM only allowed while collecting data)

@azamiqbal, you could follow the image below to understand on what @wroos has tried to show.

In the survey tab of your XLSForm:

Data entry screen as seen in Enketo:

Data entry screen as seen in Enketo:

Data entry screen as seen in Enketo:

Data entry screen as seen in Enketo:

Reference XLSForm:

TIME.xlsx (9.9 KB)


All you need to calculate here is the decimal-time. For this you could do as follows:

  • First, you will need to convert the time to 24 hours. This will be easy for the calculations.
  • Second, you will need to get the decimal value of 8 AM. You can do this by dividing as follows: 8 div 24. So, 8 AM in decimal value is 0.333. Similarly, you will also need to get the decimal value of 2 PM. So 2 PM in 24 hours should be 14 hours. You can get the decimal value of 14 hours by dividing as follows: 14 div 24. So, 2 PM (or 14 hours) in decimal value is 0.583. As you want to constraint till 2 PM you can use the decimal value of 0.584.

The rest if the use of if-statement, note and relevant to make it a constraint.

Thank you once again @wroos for sharing this with the community :clap: Expecting the same in the upcoming days too :heart: