cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rgentile
Frequent Visitor

Trigger condition comparing column date with Modified date

Hello,

 

I am trying to create a trigger condition for use on SharePoint's "When an item is created or modified" trigger but can't get it working.

 

The condition I want to test is if the date in a SharePoint list text column is equal to the date in the SharePoint's default Modified column.

 

Here is trigger condition I am trying: @equals(triggerBody()?['tiered'],triggerBody()?['Modified'])

 

Tiered is a text field in a SharePoint list and its value is set in a Power App using Text(Now(),ShortDateTime).

 

The SharePoint list Modified column is set to use the Standard Display Format.

 

When I view the list the columns match but the trigger condition doesn't seem to ever evaluate to true.

date-columns.png

So, I created to variables in my flow and set the values to using the Dynamic content values from the trigger:

 

variable-config.png

 

and I get 

 

variables.png

 

So, it appears that although they look the same when viewing the list, the values are actually different.  

 

I'm guessing I might need to format them so they look the same (I'll take any suggestions on how to do that) or perhaps I need to change my Tiered SharePoint column from text to date.

 

Can anyone please steer me in the right direction?

 

Thanks,

 

robertg

1 ACCEPTED SOLUTION

Accepted Solutions

I ended up determining the difference between the two dates and times.  But rather than do this in a trigger condition I just added a condition inside the Flow.  So if the time difference was 2 or less I sent the email, otherwise did nothing.

 

This is the code to determine the difference:

div(div(mul(sub(int(variables('modified')),int(variables('tiered'))),100),1000000000),60)
 
Thanks again for the suggestion to use a date field @abm!
 
robertg

View solution in original post

5 REPLIES 5
abm
Super User III
Super User III

Hi @rgentile 

 

Not sure why the modified not showing the date only format?

 

If you looking only the date to compare then you could do the following

 

image.png

 

Above I have two compose and formatDateTime() expressions. Following are the expressions I used.

 

formatDateTime(variables('modified'),'yyyy-MM-dd')
 
formatDateTime(variables('tier'),'yyyy-MM-dd')
 
Here I have formatted both dates to yyyy-MM-dd format. Next step you can compare both values and implement the rest of the logic.
 
Ideally I would use tier field as DateTime similar like modified. But the above logic could work as well.
 
Here is my run result
 
image.png
Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
rgentile
Frequent Visitor

Thanks for the reply and the code @abm.  Is there a way to add time to the date when I compare them?  I need to make sure the date and time match.   

 

I was thinking perhaps my problem was related to the tier being a text field so thanks for confirming my thought that it could be part of the problem.  I appreciate your time and help.

 

robertg

I tried changing the Tiered column to a date format and the formats match.  But I see there is a bit of a time difference so I think it would always return false.  

 

variables-same-format.png

I'm thinking of trying to to determine if the times are within say a minute of each other rather than equal.  Sound reasonable?

 

Thanks

I ended up determining the difference between the two dates and times.  But rather than do this in a trigger condition I just added a condition inside the Flow.  So if the time difference was 2 or less I sent the email, otherwise did nothing.

 

This is the code to determine the difference:

div(div(mul(sub(int(variables('modified')),int(variables('tiered'))),100),1000000000),60)
 
Thanks again for the suggestion to use a date field @abm!
 
robertg

View solution in original post

abm
Super User III
Super User III

Hi @rgentile 

 

Yes thats the milli seconds difference. So if you want to ignore then use the format yyyy-MM-dd hh:mm:ss

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,248)