# Number of Business Days in a month (excluding weekends)

Hi AlI,

I am explaining how to calculate number of business days in a month (excluding weekends).

Below are the steps.

• VD_Date = CurrentDate()

• VD_FirstDayMonth

=RelativeDate(LastDayOfMonth(CurrentDate());-ToNumber(Left(FormatDate(LastDayOfMonth(CurrentDate()) ;”dd/MM/yy”);2))+1)

• VD_LastDayMonth

=LastDayOfMonth(CurrentDate())

=DaysBetween(RelativeDate([VD_FirstDayMonth];Floor(DayNumberOfWeek([VD_FirstDayMonth])/6)*(8-DayNumberOfWeek([VD_FirstDayMonth])));RelativeDate([VD_LastDayMonth];Floor(DayNumberOfWeek([VD_LastDayMonth])/6)*(8-DayNumberOfWeek([VD_LastDayMonth]))))-(Floor(DaysBetween(RelativeDate(RelativeDate([VD_FirstDayMonth];Floor(DayNumberOfWeek([VD_FirstDayMonth])/6)*(8-DayNumberOfWeek([VD_FirstDayMonth])));(DayNumberOfWeek(RelativeDate([VD_FirstDayMonth];Floor(DayNumberOfWeek([VD_FirstDayMonth])/6)*(8-DayNumberOfWeek([VD_FirstDayMonth]))))+1)*-1);RelativeDate([VD_LastDayMonth];Floor(DayNumberOfWeek([VD_LastDayMonth])/6)*(8-DayNumberOfWeek([VD_LastDayMonth]))))/7)*2)

Final Report as below.

Thanks,

Sreeni

### Assigned Tags

1 Comment
You must be Logged on to comment or reply to a post.

Couple of points:

• The results that you are showing is wrong. For example in your screenshot you got 21 business days for June(this month) - But it is should have been 22.
• You are using a very complicated way to achieve what you want.
• try to understand the logic applied below and test it to see if the results are good.

I created separate variables for your understanding, merge them into one as needed. There could be more simpler ways around too.

VD_FirstDayMonth= RelativeDate([Date];-1*DayNumberOfMonth([Date])+1)

VD_LastDayMonth= LastDayOfMonth([Date])

VD_TotalNumberDaysInMonth= DaysBetween([VD_FirstDayMonth];[VD_LastDayMonth])+1

VD_DayNumberOfWeekFIrstDay= DayNumberOfWeek([VD_FirstDayMonth])

VD_FirstWeekendDayNumber= If (7-[VD_DayNumberOfWeekFIrstDay])=0 Then (If [VD_TotalNumberDaysInMonth]=30 Then 2 Else 3) Else (7-[VD_DayNumberOfWeekFIrstDay])

VD_NumberofWeekendDaysInMonth= If [VD_FirstWeekendDayNumber]+28<[VD_TotalNumberDaysInMonth] Then 10 Else (If [VD_FirstWeekendDayNumber]+27<[VD_TotalNumberDaysInMonth] Then 9 Else 8)