cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
isaac1
Helper II
Helper II

Compare TODAYs date to DUE DATE variable and test against numeric quantity

I have a situation where I'm struggling to put together the correct components of String variables, addDays, expressions and logic.  Wondering if someone could basically help me get started with suggesting what the proper components might be.

 

  1. I have a GetItems step, which returns ONE sharepoint list record telling me some 'configuration options' - telling me the values from a Number column [DaysBeforeDueDateToNotify] (say the value might be 5).  I can put this in a flow variable? (Should it be Float?)
  2. I have a GetItems step, which returns the same ONE sharepoint list record telling me another 'configuration options' - telling me the values from a Date column [DueDate].  I can put this in a flow variable too.  (Should it be String?)
  3. I have a GetItems step, which returns potentially multiple Sharepoint list records that meet a certain criteria.  In this step I want to do the following:
    1. Apply to each
    2. Condition:  If the difference between Today's Date and [DueDate] (from step 2) is LESS than step 1's [DaysBeforeDueDateToNotify], then I want to do some stuff (I can probably figure this part out - the stuff to do).

 

Does this make sense - what I'm trying to do?  If today is March 1st, and the DueDate configuration (coming from that single sharepoint record) is March 4th, and the DaysBeforeDueDateToNotify configuration (coming from that single sharepoint record) is 3, then 4th minus 3 = 1st = YES we want to "do stuff".

 

I'm just struggling with the dates, vs. strings, vs. variables, and expressions for the conditional logic.

 

PS - another way I would be fine structuring this would be:

  1. get the DueDate value from the single sharepoint record
  2. get the DaysBeforeDueDateToNotify number value from the single sharepoint record
  3. determine if (Today minus DueDate) < (DaysBeforeDueDateToNotify) and IF SO, then proceed to DO stuff...and I can handle that part.  

That's all

1 ACCEPTED SOLUTION

Accepted Solutions
mahoneypat
Dual Super User
Dual Super User

You can use a Filter array step to filter your SharePoint list items based on your due date column and a given # days from today (utcNow()).  Example syntax is below.  Replace 5 with your # of days variable.  Use greaterOrEquals or lessOrEquals depending on the order you prefer.

 

mahoneypat_0-1617149640062.png

 

greaterOrEquals(addDays(formatdatetime(utcNow()), 5), item()?['Created'])

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Dual Super User
Dual Super User

You can use a Filter array step to filter your SharePoint list items based on your due date column and a given # days from today (utcNow()).  Example syntax is below.  Replace 5 with your # of days variable.  Use greaterOrEquals or lessOrEquals depending on the order you prefer.

 

mahoneypat_0-1617149640062.png

 

greaterOrEquals(addDays(formatdatetime(utcNow()), 5), item()?['Created'])

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


isaac1
Helper II
Helper II

Thanks - I am getting close.  I now have a condition where I want two things to be true:  that the column Date_Stage5 is null, and the column DateReminderSent_Stage5 is null.  

 

Recently, in this post , I established (and have proved true), that an acceptable syntax for one of those conditions is:  (Date_Stage5 eq null)  (just like that - case sensitive and including parenthesis).

So, in this time, I have tried (in the ODATA filter portion of GetItems):  and((Date_Stage5 eq null),(DateReminderSent_Stage5 eq null))

 

but the error is:  The function operator 'and' is not supported or its usage is invalid.

(I've also tried and with the @ sign, like @And, but get:   The expression "@and((Date_Stage5 eq null),(DateReminderSent_Stage5 eq null))" is not valid. Creating query failed.

isaac1
Helper II
Helper II

Addition:  I solved this problem for the moment by eliminating the ODATA filter (bringing in the whole list), and THEN in my 'action' part of the flow, having a Condition - 3 of them actually - including 2 about those two columns being equal to null.  That worked fine, but I still yearn to have a better grasp of ODATA expressions, as they seem like the most picky syntax thing ever...but quite handy.

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,374)