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

AddMinutes condition not reading Converted 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 30 minutes, the Flow should post a message as Flow bot to a Teams channel.

 

Time is displayed in the API as a 12-digit string in U.S. eastern time; I'm converting it to UTC in my Flow, which is testing successfully.

 

I then have a conditional: If converted time is greater than AddMinutes(utcNow(),-30), post the message to the Teams channel.

 

That conditional is not working. Even when the timestamp in the API is within the last 30 minutes, the conditional comes back as false. It never posts the message.

 

I've tried the conditional two ways; you can see that plus the output of converted time and how I'm converting time in the screenshots below.

 

Any guidance would be appreciated!

 

FLOW3.jpgFLOW2.jpgFLOW1.jpg

FLOW4.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
ianhillmedia
Helper I
Helper I

Hey all! This is resolved. Thanks for your help working through this with me!

 

When I converted to Eastern I had been using this:

 

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')

 

I needed to capitalize the hours; this fixed it:

 

...'yyyy-MM-dd HH:mm')

 

THANK YOU again!

View solution in original post

14 REPLIES 14
Pstork1
Dual Super User
Dual Super User

It should definately be the second way of doing it.  The parameter for UTCnow() is the format pattern you want, not the time.  In your first try you are feeding it the converted time, not a format pattern.  

 

So the second set of code looks correct.  But could you show us an actual run of the flow with a compose to show the output of the time conversion and the addminutes() function?  That way we can see what is actually being compared.  That will probably identify why its not working.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

eric-cheng
Solution Sage
Solution Sage

Hi @ianhillmedia ,

 

Please check to ensure the format of both dates are in the same format.  

 

I am not in front of my pc but try formatting the utcnow() into the same format.

 

 

As mentioned above, please post the data from your run.

Sure! Any guidance would be appreciated. In this case I used AddMinutes(utcNow(),-90), just to make sure there was data from the API to capture. Screenshots below. Let me know if I can provide anything else that would help! FYI it's 12:30 p.m. ET, whichis 4:30 p.m. UTC right now. THANK YOU!

FLOW3.jpgFLOW2.jpgFLOW1.jpg

That shows the converted time.  But can you also add a compose just before the condition and use the same AddMinutes() function as in the right side of the condition.  Then we can see what is actually being compared.  The converted time is in ISO 8601 format and the add minutes should default to that format as well, so I don't think formatting is the issue.  We need to make sure the AddMinutes is putting out the time you think it is.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

Done! So here's what I get when I Compose:

 

 

addMinutes(utcNow(body('Convert_time_zone')),-90)

 

 

Screen Shot 2021-07-11 at 1.12.01 PM.png

 

I also Composed:

 

 

addMinutes(utcNow(),-90)

 

 

 

And got 

 

2.png

In both cases, the condition still returned...

Screen Shot 2021-07-11 at 1.17.30 PM.png

 

THANK YOU for your help!

Try this. Got it working in mine.  

 

formatDateTime(addMinutes(utcNow(),-30),'yyyy-MM-dd HH:mm:ssZ')

 

Screenshot_20210712-032046_Chrome.jpg

Add a formatDateTime() function around the addminutes() to make sure its in same format as the adjust time zone.  Use this format.  'yyyy-MM-dd hh:mm:ssZ'



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

No luck, unfortunately. 

 

I used:

formatDateTime(addMinutes(utcNow(),-60),'yyyy-MM-dd HH:mm:ssZ')

 

Results below.

 

Screen Shot 2021-07-11 at 6.14.30 PM.pngScreen Shot 2021-07-11 at 6.14.49 PM.png

ianhillmedia
Helper I
Helper I

And here's a weird rub. This — expression less than Converted Time — always returns the condition as false, no matter what. It should return true when Converted Time is within 60 minutes.

Screen Shot 2021-07-11 at 6.32.50 PM.png

 

Meanwhile, this — expression greater than Converted Time — always returns as true, even when Converted Time is within 60 minutes and it should be false.

 

Screen Shot 2021-07-11 at 6.33.05 PM.png

Not having any luck, unfortunately. See below.

ianhillmedia
Helper I
Helper I

Still no luck.

I've suggested several times now that you add a compose statement just before the condition and put the right side of your condition in there.  That will show you exactly what your date and time is comparing to.  Then we can figure out why its not comparing correctly.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

ianhillmedia
Helper I
Helper I

Hi! Thanks for the reply; I believe that's what I did when you first suggested it — see my comment from seven hours ago — but I just did it again, see below. I did a compose with:

 

formatDateTime(addMinutes(utcnow(),-30),'yyyy-MM-dd HH:mm:ssZ')

Screen Shot 2021-07-11 at 8.44.28 PM.png

 

And one with:

formatDateTime(addMinutes(utcnow(body('Convert_time_zone')),-30),'yyyy-MM-dd HH:mm:ssZ')

 

Screen Shot 2021-07-11 at 9.00.46 PM.png

 

That said, I think I've narrowed the issue down.

 

I can get it to return true for any timestamp before 1 p.m. EST using something like:

 

formatDateTime(addMinutes(utcNow(),-700),'yyyy-MM-dd HH:mm:ssZ')

 

Anything with a timestamp that starts at 1 p.m. is not being compared to utcNow.

 

Wondering if that can help point us in the right direction?

 

And apologies for the multiple "no luck yet" comments above!

 

 

 

 

 

 

 

ianhillmedia
Helper I
Helper I

Hey all! This is resolved. Thanks for your help working through this with me!

 

When I converted to Eastern I had been using this:

 

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')

 

I needed to capitalize the hours; this fixed it:

 

...'yyyy-MM-dd HH:mm')

 

THANK YOU again!

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

Users online (1,283)