Summary This wiki outlines how to configure a Power Automate Flow to determine the period (in Days) between 2 define dates.
Scenario You are renting material to clients and wish to determine how long your clients will be renting the equipment for by defining the rental period start date and end date. You do not wish to manually count the days between the start and end date. Therefore you decide to build a power automate flow to do it for you. However, Power Automate does not have a function that counts the days between 2 dates, making this automation slightly harder to configure. Below is a step-by-step workaround to defining the period between your start and end date.
Resolution Step 1: Set a variable for your Rental Start Date.
Step 2: Set a variable for your Rental End Date.
Step 3: Define a Compose action card with this expression "ticks(variables('Rental Start Date'))". The "Ticks" function returns 100-nanosecond intervals number corresponding to a specific date and time. Therefore, providing a unique interval number to our Start Date which we will be able to use later on.
Step 4: Define another Compose action card with the same expression but now for your end date "ticks(variables('Rental End Date'))". The "Ticks" function will now provide a unique interval number to our End Date.
Step 5: Define a third Compose action card with the following expression "sub(outputs('End_Date_Ticks'),outputs('Start_Date_Ticks'))". This expression is used to substract the Start Date Interval number from the End Date Interval number, allowing us to define a unique interval number again, but this time for our Rental Duration.
Step 6: Define a new variable called Rental Duration with the following expression "div(outputs('Difference_in_Ticks'),864000000000)". This expression divides our Unique Rental Duration Interval number by (100-nanosecond * # of seconds found in a day) providing us with the duration in "Days" found between our Start and End Dates.