I have a flow set up to use the ArcGIS "When a record is updated in a feature layer" trigger, and send an email with information about the feature layer. The feature layer was created with Survey123 Connect. I have a date field (WODate) in the form that I'd like to pass through on the email. However, Survey123 likes to use Unix instead of an easily readable format, so I get emails saying "Work Order Submitted on 1670432400000". I've gone through a couple different calculations that I've found here on Geonet and on other non-Esri forums, but none of them seem to be working. Any suggestions for how I can get "1670432400000" to read as "12/7/22" or "12/7/22 12:00 pm"?
These are the options I've tried so far:
formatDateTime(addSeconds('1970-1-1', Div(triggerOutputs()?['body/feature/attributes/WODate'],1000)), 'M/d/yy h:mm tt')
addseconds('1/1/1970', Div(WODate,1000) , 'MM/dd/yy')
What outputs do you get with formatDateTime?
You might need a conversion in there. Give convertFromUtc a try. Note the time zone parameter.
convertFromUtc(concat(addseconds('1970-1-1', Div(triggerOutputs()?['body/feature/attributes/WODate'],1000),'yyyy-MM-dd hh:mm:ss'),'Z') ,'Pacific Standard Time','yyyy-MM-dd hh:mm:ss')
Thanks, I'm going to give this a try!
Update: Did not work. It just returned the whole calculation as a string. I copy/pasted the conversion you gave, and just updated the time zone, but it returned this in my email:
convertFromUtc(concat(addseconds('1970-1-1', Div(triggerOutputs()?[1671037200000],1000),'yyyy-MM-dd hh:mm:ss'),'Z') ,'Eastern Standard Time','yyyy-MM-dd hh:mm:ss')
@MT_JenAmes This post walks you through the steps to convert the the Epoch date to a human readable date.
I walked through the steps to convert the value you shared, 1670432400000, and converted it into the value are looking for with the following flow.
In the 'Variable - Epoch Date' initialization, the expression is:
div(1670432400000, 1000)
In the 'Variable - Human Readable Date' initialization, the expression is:
addSeconds('1970-1-1',variables('Unix Timestamp'), 'yyyy-MM-dd hh:mm:ss')
After testing the flow, here are the values:
What is the output you are getting when you try and convert the values?
How do I get this information into a flow like this then?
Because I don't have my fields available as an option to input for the value in the initial variable where I currently have it lined up. These are the only dynamic content options I have
And if I try to put the variable in after the "Fetch updates..." I get an error saying that I can't set a variable that late in the flow.
I copy/pasted the date field into the first initialize variable value question, and tried to save the flow, and it won't let me, says it's an invalid integer.
You cannot initialize a variable that late in the flow, but you can use the 'Set Variable' action to to set the variable's value as your 'Send Notification' iterator goes through each of the records in the webhooks payload from the 'Fetch Updates' action.