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

View solution in original post

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,391)