HOW TO

Display time in readable format when concatenated with text values in ArcGIS Survey123 Connect

Last Published: May 9, 2024

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.

The survey form.

Follow the workflow in this article to display time in a readable format when concatenated with text values in ArcGIS Survey123 Connect.

Procedure

  1. In ArcGIS Survey123 Connect, open the survey's XLSForm.
  2. Create a survey question to input the text value.
    1. In the survey worksheet, in the type column, select text from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the question is named my_id and labeled ID name.
  3. Create a survey question to input the date or time value.
    1. In a new row, in the type column, select date, time, or dateTime from the drop-down list. In this example, time is selected.
    2. Specify the values in the name and label columns. In this example, the question is named my_time and labeled Time.
The text and time questions added to the XLSForm.

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.

  1. Create a note to return the time in 24-hour time.
    1. In a new row, in the type column, select note from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the note is named my_test and labeled '24 hour time.'
    3. In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
    4. In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
format-date(${my_time}, '%h:%M')
  1. Create a note to return only the hour of the time in 12-hour time.
    1. In a new row, in the type column, select note from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the note is named my_hour and labeled Hour.
    3. In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
    4. 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')))
  1. Create a note to return only the minute of the time.
    1. In a new row, in the type column, select note from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the note is named my_min and labeled Min.
    3. In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
    4. In the calculation column, insert the following expression. If necessary, replace the question name in the expression accordingly.
format-date(${my_time}, '%M')

Three notes with calculations in the XLSForm.

  1. Create a note to calculate and display the period in AM or PM.
    1. In a new row, in the type column, select note from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the note is named my_ampm and labeled AMPM.
    3. In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
    4. 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')
  1. Create a note to concatenate the time components.
    1. In a new row, in the type column, select note from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the note is named concattime and labeled Concat Time.
    3. In the appearance column, select hidden from the drop-down list to hide the note question in the survey.
    4. 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})
  1. Create a note to concatenate the text and time values.
    1. In a new row, in the type column, select note from the drop-down list.
    2. Specify the values in the name and label columns. In this example, the note is named myconcat and labeled My Concat Time.
    3. 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.

Three more notes with calculations in the XLSForm.
  1. 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.

The survey with the time in a readable format when concatenated with text values.

Article ID: 000032395

Software:
  • ArcGIS Survey123 Connect

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options