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

Condition Comparing Dates is Always Resulting True

Hi All,

I have a flow scheduled monthly to send an email if an item in a list has a due date within the next 34 days (ie next month). However, when I run the flow, it results true for every item, even those with due dates months from now. Any idea what I am missing?

AAallday_0-1611770306937.png

 

"isTrigger":false,

"operationName": "Condition", "operationDefinition":

{"type":"If","expression":
{"and":[
{"lessOrEquals":["@formatDateTime(outputs('Compose'),'yyyy-mm-dd')","@addDays(utcNow(),34,'yyyy-mm-dd')"]},
{"or":[{"equals":["@items('Apply_to_each')?['Status/Value']","Pending"]},{"equals":["@items('Apply_to_each')?['Status/Value']","Delayed"]}]}]},
"actions": {"Send_an_email_(V2)": {"type":"OpenApiConnection",

"inputs":{"host":{"connectionName":"shared_office365","operationId":"SendEmailV2","apiId":"/providers/Microsoft.PowerApps/apis/shared_office365"},

"parameters":{"emailMessage/To":"email@address","emailMessage/Subject":"test","emailMessage/Body":"<p>aasdfasdfasdf</p>"},"authentication":"@parameters('$authentication')"},

"runAfter":{}}},

"runAfter":{"Compose":["Succeeded"]}}}

1 ACCEPTED SOLUTION

Accepted Solutions
tom_riha
Super User
Super User

Hello @AAallday ,

can you add 2 Compose actions just before the condition, put @formatDateTime(outputs('Compose'),'yyyy-mm-dd') into one of them and @addDays(utcNow(),34,'yyyy-mm-dd') into the other? You'll then see in the run history what dates enter the condition and if it should return true/false.

Also, the date format you use ('yyyy-mm-dd') is not right. Lowercase 'mm' = minutes. For months it must be upper case 'MM'. The format should be 'yyyy-MM-dd'.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

2 REPLIES 2
tom_riha
Super User
Super User

Hello @AAallday ,

can you add 2 Compose actions just before the condition, put @formatDateTime(outputs('Compose'),'yyyy-mm-dd') into one of them and @addDays(utcNow(),34,'yyyy-mm-dd') into the other? You'll then see in the run history what dates enter the condition and if it should return true/false.

Also, the date format you use ('yyyy-mm-dd') is not right. Lowercase 'mm' = minutes. For months it must be upper case 'MM'. The format should be 'yyyy-MM-dd'.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

View solution in original post

Looks like this works -- thank you! and thank you for the formatting catch!

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,107)