Converting time using Power Automate and Survey123

4309
9
Jump to solution
01-28-2021 06:14 AM
DaveK
by
Occasional Contributor

Hello! 

I'm using Power Automate to send a confirmation email when a survey is submitted. I have a dateTime field within my survey and I am interested in converting the time to be understandable within an email. As I understand it the survey contains the date/time in Epoch time. I found an article explaining how to perform this conversion but I seem to be doing something wrong, because the Power Automate process throws an error on my expression. 

Link to the conversion article - https://support.esri.com/en/technical-article/000023954

And here is my expression - 

addSeconds('1970-1-1', Div(triggerBody()?['feature']?['attributes']?['datetime'],1000))

 

If anyone has done this conversion before and has information it would be appreciated! 

Thanks. 

1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

I think you are just missing the format string at the end.

  • In Power Automate, click on the body input box of your email action
  • Select Dynamic Content
  • Switch to the Expression tab
  • Type addSeconds('1970-1-1',Div(
  • Then insert the date value from the survey (switching momentarily to dynamic content to select your date question in the survey).
  • Your expression will look something like this: addSeconds('1970-1-1',Div(triggerBody()?['feature']?['attributes']?['yourdatequestion']
  • Now add ,1000),'yyyy-MM-dd')
  • Your final expression will be something like this

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

View solution in original post

9 Replies
IsmaelChivite
Esri Notable Contributor

I think you are just missing the format string at the end.

  • In Power Automate, click on the body input box of your email action
  • Select Dynamic Content
  • Switch to the Expression tab
  • Type addSeconds('1970-1-1',Div(
  • Then insert the date value from the survey (switching momentarily to dynamic content to select your date question in the survey).
  • Your expression will look something like this: addSeconds('1970-1-1',Div(triggerBody()?['feature']?['attributes']?['yourdatequestion']
  • Now add ,1000),'yyyy-MM-dd')
  • Your final expression will be something like this

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

RutledgeNicholas
New Contributor III

@IsmaelChivite, I've followed your instructions but my conversion is failing using the code. Following your exact instructions are insert the following code but then showing as an invalid code. Any changes to this process or pointer for what I am doing incorrectly?

addSeconds('1970-1-1',Div(triggerBody()?['body/feature/attributes/submissionDate'],1000,'yyyy-MM-dd'))
0 Kudos
Ursu_Lacramioara
New Contributor III

Hi Ismael @IsmaelChivite 

I used your logic for the Date/Time and I don't get the correct time in the email. I created a test record set to  Dec 25, 2021 @1pm and the email was generated for Date as Dec 24, 2021 @7pm. any suggestions? Thank you!

Lacri

0 Kudos
IsmaelChivite
Esri Notable Contributor

@Ursu_Lacramioara  Date objects in an esriFieldTypeDate column are stored in UTC. That explains the difference you see.

You can convert the time zone as shown in the diagram below. If you are using the Convert time zone module, you do not need to include the date format parameter in the addSeconds operation.

 

IsmaelChivite_0-1692654260751.png

 

 

 

RutledgeNicholas
New Contributor III

I'm trying to convert my date to MM-DD-YYYY format and I've followed the instructions but my conversion is failing using the code. Following the exact instructions that are written and inserting the following code, but then showing as an invalid code. Any changes to this process or pointer for what I am doing incorrectly?

addSeconds('1970-1-1',Div(triggerBody()?['body/feature/attributes/submissionDate'],1000,'yyyy-MM-dd'))
0 Kudos
Ursu_Lacramioara
New Contributor III

Hi Nicholas - this is what i have in my flows for Add to Time:

Div(triggerOutputs()?['body/feature/attributes/SiteVisitDate'],1000)

 

Ursu_Lacramioara_0-1699024445233.png

 

RutledgeNicholas
New Contributor III

@Ursu_Lacramioara Thanks! This seem to have fixed my first issue. Since my Date field is a date only field, are you aware of any ways of getting the Thh:mm:ss:ms portion of the date field removed?

 

0 Kudos
Ursu_Lacramioara
New Contributor III

do you have this, where Calculated Time equals to body ('Add_to_time')

Ursu_Lacramioara_0-1699026131641.png

 

RutledgeNicholas
New Contributor III

@Ursu_Lacramioara This worked perfectly! Thank you!!!

RutledgeNicholas_0-1699026735771.png

 

 

0 Kudos