How to calculate number of weekdays without SAT/SUN between two dates

Hello all,
How to calculate total number of WEEKDAYS between two dates?
Custome activity I used is giving me incorrect result. I want to exclude Saturday and Sunday.

Hi @7387023380 - If you are allowed to use external packageâ€¦Please try thisâ€¦

1 Like

1 Like

Hi @sarathi125 â€¦Thanksâ€¦but it is printing all dates between 2 given datesâ€¦but the user asked only for business days excluding weekendsâ€¦Do we have to tweak your flow?

We can check if the day of the date is Saturday and Sunday we can ignore those days.

Check this xaml, included to ignore Saturday and Sunday

GetDatesBetween2Dates.xaml (6.7 KB)

2 Likes

I have tried this packageâ€¦ It is I guess including Saturday in working daysâ€¦ in calculation it is giving one day more than weekdays.

Thanks @sarathi125 â€¦ I only want the number of weekdays between two dates in INT formatâ€¦ how can I get thisâ€¦?

@7387023380 - Nopeâ€¦its working fineâ€¦Please have a look hereâ€¦You can see it did not printed 20 and 21.

1 Like

Check this below code, @7387023380
TotalDays = 1 + ((Cdate(â€ś02/14/2021â€ť) - Cdate(â€ś02/01/2021â€ť)).TotalDays * 5 - (CDate(â€ś02/01/2021â€ť).DayOfWeek - Cdate(â€ś02/14/2021â€ť).DayOfWeek) * 2) / 7.
And code is in the form of,
TotalDays = 1 + (EndDate - StartDate).TotalDays * 5 - (StartDate.DayOfWeek - EndDate .DayOfWeek) * 2) / 7.
EndDate and StartDate should be in - â€śMM/dd/yyyyâ€ť format

This will give you the total days excluding the Saturday and Sunday.