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

@7387023380 ,GetDatesBetween2Dates.xaml (6.0 KB)

Check this xaml, it may help you.

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?

@prasath17 ,

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

@7387023380 ,

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.
Hope this may help you :slight_smile:

2 Likes

Thanks @sarathi125- ur code is working for me
@prasath17- this packg activity also working @Manish540 - got the solution…
Thanks all for quick solution

Update the workflow to get only Weekend counts.
GetWeekendCount.xaml (8.7 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.