Select to view content in your preferred language

Convert AGOL Hosted Feature Service Creation Date in Power Automate Flow

314
8
Jump to solution
05-20-2024 10:52 AM
LeviCecil
Regular Contributor

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. 

0 Kudos
1 Solution

Accepted Solutions
NataliyaLys
Occasional Contributor III

Add it into your email body and an expression/function 

NataliyaLys_1-1716239677076.png

 

 

NataliyaLys_0-1716239629321.png

 

View solution in original post

8 Replies
DominicRoberge2
Occasional Contributor III

@LeviCecil 

 

try this (it's a expression): 

convertTimeZone(addSeconds('1970-1-1', Div(YOURFIELD NAME,1000),'MM/dd/yyyy hh:mm:ss tt'),'UTC','Central Standard Time','MM/dd/yyyy hh:mm:ss tt')
 
Hope this can help you
 
0 Kudos
NataliyaLys
Occasional Contributor III

This is an expression that I have, and it works as expected: 

convertTimeZone(addSeconds('1970-1-1', Div(items('Apply_to_each_3')?['Attributes/CreationDate'],1000),'MM/dd/yyyy hh:mm:ss tt'),'UTC','Central Standard Time','MM/dd/yyyy hh:mm:ss tt')
0 Kudos
LeviCecil
Regular Contributor

Thanks for this. Would you do this inside a compose trigger and use the output in the email body?

0 Kudos
NataliyaLys
Occasional Contributor III

Add it into your email body and an expression/function 

NataliyaLys_1-1716239677076.png

 

 

NataliyaLys_0-1716239629321.png

 

LeviCecil
Regular Contributor

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.".'.'."

0 Kudos
RobertAnderson3
MVP Regular Contributor

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.

0 Kudos
LeviCecil
Regular Contributor

Ah, thanks! I tried it again and it worked! 

0 Kudos
Sean_Works
New Contributor

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

0 Kudos