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!
Solved! Go to Solution.
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!
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.
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!
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.
Done! So here's what I get when I Compose:
addMinutes(utcNow(body('Convert_time_zone')),-90)
I also Composed:
addMinutes(utcNow(),-90)
And got
In both cases, the condition still returned...
THANK YOU for your help!
Try this. Got it working in mine.
formatDateTime(addMinutes(utcNow(),-30),'yyyy-MM-dd HH:mm:ssZ')
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'
No luck, unfortunately.
I used:
formatDateTime(addMinutes(utcNow(),-60),'yyyy-MM-dd HH:mm:ssZ')
Results below.
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.
Meanwhile, this — expression greater than Converted Time — always returns as true, even when Converted Time is within 60 minutes and it should be false.
Not having any luck, unfortunately. See below.
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.
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')
And one with:
formatDateTime(addMinutes(utcnow(body('Convert_time_zone')),-30),'yyyy-MM-dd HH:mm:ssZ')
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!
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!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
68 | |
22 | |
16 | |
16 | |
11 |
User | Count |
---|---|
130 | |
42 | |
32 | |
32 | |
28 |