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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,707)