cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ianhillmedia
Helper I
Helper I

Convert 12-digit string to UTC date/time?

Hello all!

 

I'm writing a Flow that scrapes an API for data that includes a timestamp. If the timestamp is within the last 1 minute, the Flow should post a message as Flow bot to a Teams channel.

 

The challenge: the timestamp is a 12-digit string formatted yyyymmddhhmm. It's also in U.S. Eastern time. See screenshot below.

 

The Flow I've written below returns as a success in tests, but it doesn't post to the Teams channel as expected because the timestamp is greater than addMinutes condition always returns false, even though there is data in the API that should result in the condition returning true.

 

I'm pretty sure this is because the Flow is not reading the timestamp as a properly-formatted time and date in UTC. TBH, I didn't expect it to to test successfully at all — the fact that the condition is reading the string as a time and date at all is a surprise to me.

 

Because of that, I'm hoping the solution will just be that I need to convert the timestamp to the proper time. I'm hoping I don't have to use compose to separate and rebuild the timestamp.

 

Either way, I have no experience with converting time or compose. 

 

Any direction or guidance would be appreciated!

 

Screen Shot 2021-07-10 at 9.38.00 AM.pngScreen Shot 2021-07-10 at 9.39.34 AM.png

1 ACCEPTED SOLUTION

Accepted Solutions
ianhillmedia
Helper I
Helper I

Resolved, and a bit easier than I thought.

 

In the screenshot below...

 

Compose simply pulls the timestamp. I'm not sure why this step is needed, but without it, the Flow fails.

 

Compose 2 converts timestamp into a string:

string(outputs('Compose'))

 

Eastern then pulls timestamp into substrings, re-assembles them as yyyy-mm-dd hh:mm and formats that as time.

formatDateTime(concat(substring(outputs('Compose_2'),0,4),'-',substring(outputs('Compose_2'),4,2),'-',substring(outputs('Compose_2'),6,2),' ',substring(outputs('Compose_2'),8,2),':',substring(outputs('Compose_2'),10,2)),'yyyy-MM-dd hh:mm')

 

Convert to UTC, and it should work (it's not, but that's another post.)

 

Thanks for reading this as I worked through the issue!

Screen Shot 2021-07-10 at 4.18.27 PM.png

View solution in original post

3 REPLIES 3
ianhillmedia
Helper I
Helper I

Getting closer, but this is ugly.

 

Screen Shot 2021-07-10 at 2.56.45 PM.png

 

 

ianhillmedia
Helper I
Helper I

Resolved, and a bit easier than I thought.

 

In the screenshot below...

 

Compose simply pulls the timestamp. I'm not sure why this step is needed, but without it, the Flow fails.

 

Compose 2 converts timestamp into a string:

string(outputs('Compose'))

 

Eastern then pulls timestamp into substrings, re-assembles them as yyyy-mm-dd hh:mm and formats that as time.

formatDateTime(concat(substring(outputs('Compose_2'),0,4),'-',substring(outputs('Compose_2'),4,2),'-',substring(outputs('Compose_2'),6,2),' ',substring(outputs('Compose_2'),8,2),':',substring(outputs('Compose_2'),10,2)),'yyyy-MM-dd hh:mm')

 

Convert to UTC, and it should work (it's not, but that's another post.)

 

Thanks for reading this as I worked through the issue!

Screen Shot 2021-07-10 at 4.18.27 PM.png

Hi @ianhillmedia 

Glad that your issue is solved.

Thanks for your posting here and sharing the resolution in the forum as it would be helpful to anyone who encounters similar issues.

Best Regards

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (1,217)