Managing Time and Date from Survey123 in Microsoft Flow

7190
18
01-21-2019 09:54 PM
KhairulAmri2
New Contributor II
3 18 7,190

Webhook capability in Survey123 is very helpful to automate process without make a code. you can follow this link for the details : https://community.esri.com/groups/survey123/blog/2018/07/19/automating-workflows-with-survey123-and-... 

I got some challenges when use it in Microsoft Flow especially about time and date. 

  1. originally time and date from survey123 is EPOCH format.
  2. by default time zone form survey123 is UTC.
  3. I have needs to display time and date in proper string format.

Convert EPOCH to YYYY/MM/DD HH:mm:ss

if you access time and date from field directly from dynamic content, it will display epoch time. to show time and date as YYYY/MM/DD HH:mm:sss you can use expression instead of dynamic content.

expression 

expression syntax :
addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['dateTime'],1000) , 'HH:mm:ss')
this part ['feature']?['attributes']?['dateTime'] is time field in your featureservice.
it will return time and date like this : 2019-01-22 02:00:00 (please bear in mind this is UTC time zone)
Convert from UTC to My City Time Zone :
as you can see on the picture above, I added my time expression into add to time plugin. this plugin is default from Microsoft Flow to add interval time into your exisiting time. my city time zone is UTC +7. so I added 7 in interval form and select hour in time unit options.
the result will be like this : 2019-01-16T13:00:00.0000000
its return time and date with full string format. 
Reformat time and date string:
in my case, I want to extract time from converted time and display it as short time pattern.I added Convert time zone plugin provided by microsoft flow. basically this plugin used for converting time zone, however there is an options to display format time and date format string. so I used "short time pattern" in format string options then convert time zone to same time zone due to my time has been converted in previous step by adding interval manually. 
then I can use time in email body like this :
or use converted time in event calendar like this :
here is the whole diagram :
Any inputs are welcome
Regards
Amri
18 Comments