Forum Discussion
MAVOTRP
Mar 05, 2024Copper Contributor
Do Until loop creating too many dates
Hello. I have created a flow that identifies the difference of days between Start Date and End Date in a SharePoint List. The flow then checks for weekdays and adds a row into an Excel table for each...
Rob_Elliott
Mar 06, 2024Bronze Contributor
MAVOTRP I don't know what else your flow is doing but you can have the following formula in a calculated column in your SharePoint list to calculate the difference in working days between a StartDate column and an EndDate column:
=(DATEDIF([StartDate],[EndDate],"D"))-INT(DATEDIF([StartDate],[EndDate],"D")/7)*2-IF(WEEKDAY([EndDate])<WEEKDAY([StartDate]),2,IF(OR(WEEKDAY([EndDate])=7,WEEKDAY([StartDate])=1),1,0))+1
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)
- MAVOTRPMar 07, 2024Copper ContributorHi Rob thanks for your response. The main objective of the flow is to take the individual working days between the Start and End dates in SharePoint then load them into an Excel table. The flow works fine when the number of days is 2 or more. For example:
Start Date 07/03/24 and End Date 08/03/24.
The flow correctly calculates 2 days and inputs 07/03/24 and 08/03/24 into the Excel table individually.
When it is for one day only, for example:
Start Date 07/03/24 and End Date 07/03/24.
For some reason even when my Compose - Day Difference step has an output of 0, the flow will create individual days from 07/03/24 to 07/05/24 and enter them into the Excel table. (see second screenshot in original post)
Every time there is a single day entry, it creates two months-worth of entries in Excel. But for 2 or more days, the logic works correctly and the outputs are correct.