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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,173)