Summary
When designing a flow using the 'Send an email when a survey response is submitted on Survey123' template in Microsoft Power Automate, or a scenario using the 'Send an email via Office 365 Email when a survey is submitted' template in Integromat, it is possible to insert the attributes from survey responses using dynamic fields. These values can be used in different components of the flow or scenario, such as in an email Subject or Body. However, by default, the date and time attributes are displayed as a string of numbers in the email. For instance, 8/17/2020, 1:30 PM displays as 1597644000000.
The images below show the notifications for survey responses sent in the email by Microsoft Power Automate and Integromat.
This is by design. ArcGIS Survey123 stores date and time in Epoch time (also known as Unix time) as the default time zone. Epoch time is the amount of time in seconds that has elapsed since January 1, 1970 (00:00:00 UTC).
This article provides steps to reformat the ArcGIS Survey123 date and time survey responses.
Procedure
In Microsoft Power Automate
- Add a 'Convert time zone' action.
- Under When a survey response is submitted, click the add button, and click Add an action.
- In the Choose an action window, search forĀ 'Convert time zone'.
- Click the Actions tab, and click Convert time zone.
- Convert the default time zone to the intended time zone.
- In the Convert time zone window, click the Base time box. In the pop-up window on the right, click the Expression tab. Search for and select addSeconds(timestamp, seconds, format?).
- Insert the following function in the addSeconds() expression. Ensure the survey's date/time field is inserted in the <Date_Time_field> component of the expression.
addSeconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['<Date_Time_field>'],1000))
- Click OK.
- In the Source time zone section, select (UTC) Coordinated Universal Time.
- In the Destination time zone section, select the time zone required. In this example, the time zone is (UTC-05:00) Eastern Time (US & Canada).
- In the Format string section, select a format for the converted time. In this example, Full date/time pattern (long time) - Monday, June 15, 2009 1:45:30 PM [F] is selected.
- Use the converted date/time format in the email. In the Send an email window, click the box next to the Body section. In the pop-up window on the right, click the Dynamic content tab, and select Converted time.
- Click Save to save the changes.
The following image shows the survey response notification by Microsoft Power Automate in an email with the reformatted date and time question.
In Integromat
The following workflow describes steps to insert the necessary components to the formatDate(date; format; [timezone]) expression.
- In the Microsoft 365 Email window, click the Body content box, and a window menu displays on the right. Add the formatDate expression.
- For the 'date' component of the formatDate() expression, add the addSeconds expression, and insert the necessary components according to the addSeconds(date; number) format.
- For the 'date' component, insert 1970-1-1T00:00:00.000Z.
- For the 'number' component, insert the date/time attribute from the Survey123 - Watch window, the / operator from the Math functions window, and 1000.
- For the 'format' component of the formatDate() expression, insert YYYY-MM-DD hh:mm A.
- For the '[timezone]' component of the formatDate() expression, insert the required time zone. In this example, the time zone is US/Eastern.
The image below shows the necessary components inserted to the formatDate(date; format; [timezone]) expression.
The following image shows the survey response notification by Integromat in an email with the reformatted date and time question.