Summary
Applying a constraint to a date and time questions in ArcGIS Survey123 sets a restriction on the input within a certain range. It is used when a logical requirement is required to guide respondents, or limit potential input errors in the survey form.
This article provides the steps to define constraints and calculations that confine respondents to inserting valid dates within the specified hunting season and the start and end time during the day. The image below displays an ArcGIS Survey123 Connect survey form with multiple date and time questions.
Procedure
Note:
The workflow below utilizes the date constraint for the wild turkey hunting season between 9/15/2019 and 11/14/2019 as an example.
- Open the ArcGIS Survey123 Connect XLSForm.
- Define the minimum and maximum date for the first date question as below:
- Create two calculate questions under the type field, and provide a name for both the questions under the name field. In this example, MINDATE_T is used for the first question and MAXDATE_T is used for the second question.
- Under the calculation field, specify the following formula:
- For the MINDATE_T question:
if(1=1, '2019-09-15', if(1=0, '0000-00-00','1111-11-11'))
- For the MAXDATE_T question:
if(1=1, '2019-11-14', if(1=0, '0000-00-00','1111-11-11'))
- Create the first date question under the type field, and provide a name for the question under the name field. In this example, Hunting_date_T is used.
- Under the label field, enter the question text to be displayed in the survey form.
- Specify the following formula under the constraint field.
.<=date(${MAXDATE_T}) and .>=date(${MINDATE_T})
- Define the start and end time for the first group of the time of day questions as below:
- Create two time questions under the type field, and provide a name for both the questions under the name field. In this example, Hunting_time_start_T is used for the first question and Hunting_time_end_T is used for the second question.
- Under the label field, enter the question text to be displayed in the survey form.
- Specify the following formula under the constraint field for the Hunting_time_end_T question.
.>${Hunting_time_start_T}
- Create the second date question under the type field, and provide a name for the question under the name field. In this example, Hunting_date_T2 is used.
- Under the label field, enter the question text to be displayed in the survey form.
- Specify the following formula under the constraint field.
.<=date(${MAXDATE_T}) and .>=date(${MINDATE_T}) and .>${Hunting_date_T}
- Define the start and end time for the first group of the time of day questions as below:
- Create the second group of two time questions under the type field, and provide a name for both the questions under the name field. In this example, Hunting_time_T_start2 is used for the first question and Hunting_time_T_end2 is used for the second question.
- Under the label field, enter the question text to be displayed in the survey form.
- Specify the following formula under the constraint field for the Hunting_time_T_end2 question.
.>${Hunting_time_T_start2}
Note:
If a different date range is required, create two new calculate type questions with a different name. Enter the minimum and maximum dates accordingly in the calculation field. For the new date question, reference the two new calculate questions when defining the constraint formula.