Summary
In ArcGIS Survey123 Connect, values from multiple questions can be concatenated by utilizing the concat() function. Nonetheless, when concatenating time with text values, the time is displayed in epoch time instead of a human-readable time.
The image below shows the survey displaying an epoch time when values from the 'ID name' and 'Time' questions are concatenated.
Follow the workflow in this article to display time in a readable format when concatenated with text values in ArcGIS Survey123 Connect.
Procedure
- In ArcGIS Survey123 Connect, open the survey's XLSForm.
- Create a survey question to input the text value.
- In the survey worksheet, in the type column, select text from the drop-down list.
- Specify the values in the name and label columns. In this example, the question is named my_id and labeled ID name.
- Create a survey question to input the date or time value.
- In a new row, in the type column, select date, time, or dateTime from the drop-down list. In this example, time is selected.
- Specify the values in the name and label columns. In this example, the question is named my_time and labeled Time.
To display the time in a readable format, three distinct components of time: the hour, minute, and period (AM/PM) must be extracted from the value before concatenating with the text value.
- Create a note to return the time in 24-hour time.
- In a new row, in the type column, select note from the drop-down list.
- Specify the values in the name and label columns. In this example, the note is named my_test and labeled '24 hour time.'
- In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
- In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
format-date(${my_time}, '%h:%M')
- Create a note to return only the hour of the time in 12-hour time.
- In a new row, in the type column, select note from the drop-down list.
- Specify the values in the name and label columns. In this example, the note is named my_hour and labeled Hour.
- In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
- In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
if(format-date(${my_test}, '%h') >12, (format-date(${my_test}, '%h')-12), if(format-date(${my_test}, '%h') = 0, '12', format-date(${my_test}, '%h')))
- Create a note to return only the minute of the time.
- In a new row, in the type column, select note from the drop-down list.
- Specify the values in the name and label columns. In this example, the note is named my_min and labeled Min.
- In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
- In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
format-date(${my_time}, '%M')
- Create a note to calculate and display the period in AM or PM.
- In a new row, in the type column, select note from the drop-down list.
- Specify the values in the name and label columns. In this example, the note is named my_ampm and labeled AMPM.
- In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
- In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
if(format-date(${my_time}, '%h') >11, 'PM', 'AM')
- Create a note to concatenate the time components.
- In a new row, in the type column, select note from the drop-down list.
- Specify the values in the name and label columns. In this example, the note is named concattime and labeled Concat Time.
- In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
- In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
concat(${my_hour}, ':', ${my_min}, ' ', ${my_ampm})
- Create a note to concatenate the text and time values.
- In a new row, in the type column, select note from the drop-down list.
- Specify the values in the name and label columns. In this example, the note is named myconcat and labeled My Concat Time.
- In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
${my_id} + ' ' + string(${concattime})
The image below shows the configured XLSForm.
- Save the XLSForm and publish the survey.
The image below shows the survey displaying the time in a readable format when concatenated with the text value.