Survey123 and emails through Power Automate: formatting a human readable date

2421
3
Jump to solution
06-16-2020 03:38 PM
BrettGovernanti1
New Contributor III

Hi I've got a web map used in Collector and a popup configured to send an email to a distribution group when a link is selected from the web map. A Power Automate flow runs and sends the email. What I'm having trouble with is getting a date field to display a human readable date in the email. Inside Power Automate I tried to use a Compose step to first format the date field coming from dynamic content with a "formatdatetime(triggerBody()?['feature']?['attributes']?['FIELD'],'yyyy-MM-dd')" and this just about gets it but not quite. Power Automate gives me the following error:

“Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2849': 'The template language function 'formatdatetime' expects its first parameter to be of type string. The provided value is of type 'Integer'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.”

I tried to convert the integer date to a string without much luck, but maybe my syntax is wrong. Getting the date to display sure seems like it should be easier. Any ideas what I am missing?

0 Kudos
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

From https://community.esri.com/groups/survey123/blog/2018/07/19/automating-workflows-with-survey123-and-... :

Date and DateTime questions from Survey123 are exposed in Microsoft Automate using the UNIX epoch format.  If you want to convert UNIX time into a readable date string, use the addseconds function. For example:

 

addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['mydate'],1000) , 'yyyy-MM-dd')

View solution in original post

3 Replies
IsmaelChivite
Esri Notable Contributor

From https://community.esri.com/groups/survey123/blog/2018/07/19/automating-workflows-with-survey123-and-... :

Date and DateTime questions from Survey123 are exposed in Microsoft Automate using the UNIX epoch format.  If you want to convert UNIX time into a readable date string, use the addseconds function. For example:

 

addseconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['mydate'],1000) , 'yyyy-MM-dd')
BrettGovernanti1
New Contributor III

That was it Ismael. Thank you for the assist!

0 Kudos
LindaSlattery
Occasional Contributor

@IsmaelChivite , I got this to work but I am off by 4 hours. Is there a time zone conversion that needs to be included? I am on EST. Thanks!

0 Kudos