I have a book rental PowerApp, where an evaluation in a connected Power Automate Flow regarding a Due Date in ONE entry is "misbehaving" (Datetime field in SharePoint List).
The automation should send out an email 7days prior, 2 days prior, 1 day after, and then every monday after the Due Date to remind (if the book is not returned). Everything works well, and it is only one entry where the last condition is evaluated as true, where I'd expect it to be false.
So the evaluation comes out as true to this condition:
formatDateTime(utcNow(), 'MM/dd/yyyy') IS GREATER THAN
formatDateTime(addDays(item()?['DueDate'], 1), 'MM/dd/yyyy')
Where the left side comes out (in the resulting email I doublechecked) as 12/09/2024 and the right side is 01/01/2025.
I'd expect this to be false, making the whole condition false, since the "monday evaluation" part is with an AND condition.
In every instance so far it worked as it should, no unintended emails were sent, but this one.
Tried changing the Due Date to 31st Dec 2024 in case the year is ignored for whatever reason, but the evaluation still gave the same.
The way you have it now, it is doing a string comparison and not a date comparison.
You can either update formatDateTime
to use 'yyyy-MM-dd'
or alternatively don't use formatDateTime
and let it do a date comparison.