Forum Discussion

nerdyplayer's avatar
nerdyplayer
Copper Contributor
Aug 16, 2024
Solved

date diff for power auto for 2 column

I am creating a flow that will automatically send an email once a week if the dates between 2 columns become < 30 days.   I created a switch where if the project is Closed, nothing happens. if it i...
  • Rob_Elliott's avatar
    Aug 19, 2024

    nerdyplayer you don't really want a switch for this, a normal condition will work fine.  Where the difference between the start and end date is less than 30 days and the Status is not Closed and the start date is in the future then we send the email, so in my list below this will only be Guadeloupe, Curacao and Aruba.

     

    The flow has a recurrence schedule trigger set to run once a week at 4am on Monday. The get items actin has a filter query so we're only looking at items where the start date is later than today:

     

     

    Add an apply to each and add 3 compose actions, 1 for the start date, 1 for the end date and one to calculate the difference. The expression for the date difference in days is:

    int(split(dateDifference(outputs('ComposeStart'),outputs('ComposeEnd') ), '.')[0])

     

     

    Then add a condition and select the Outputs of the ComposeDifference compose action is less than 30 and the Status Value is not equal to Closed. Leave the red if no channel empty, but add your email action int the green if yes channel.

     

     

    This will send the email about each open item where the difference is less than 30 days:

     

     

    There are ways to send just a single email but this should get you going for now.

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

     

     

     

     

     

Resources