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
Super User

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 blog
Power 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

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 blog
Power Automate Video Tutorials

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,941)