I'm trying to convert the creation date field from an AGOL hosted feature service from UTC to a date string in an email alert flow in Power Automate. I've only been able to find examples for converting dates from Survey 123 or Excel, and haven't found anything that works. Any help would be appreciated.
Solved! Go to Solution.
try this (it's a expression):
This is an expression that I have, and it works as expected:
Thanks for this. Would you do this inside a compose trigger and use the output in the email body?
Add it into your email body and an expression/function
I'm trying this in the email body after fetch updates and keep getting the error "Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The template action 'Send_email_(V2)' at line '1' and column '1842' is not valid: "The template function 'items' is not expected at this location.".'.'."
The items('Apply_to_each') implies it's being done in a loop for multiple values. How is your current flow set up? It's just taking the time from one row right? For survey mine looks like @addSeconds('1970-1-1', Div(triggerOutputs()?['body/feature/attributes/startdatetime'], 1000))
Can you share your flow and show where you're bringing the time in and converting it and placing it in the email?
There are also "Add time" and "Convert time" actions that I use in some flows that can read it properly.
Ah, thanks! I tried it again and it worked!
You may also want to explore a regular expression solution similar to the two examples below that extract date or time from a combined datetime field:
Text.ParseText.RegexParse Text: CSVDateRange TextToFind: $'''([0-9]+(/[0-9]+)+)''' StartingPosition: 0 IgnoreCase: False OccurrencePositions=> Position Matches=> DateMatch
Text.ParseText.RegexParse Text: CSVDateRange TextToFind: $'''(0?[0-9]|1[0-9]|2[0-3]):00\\s[A-Za-z]+''' StartingPosition: 0 IgnoreCase: False OccurrencePositions=> Position Matches=> TimeMatch