Working days inbetween 2 dates where Friday is the only holiday

I

Irshad Alam

I want to do a solution to find total working days inbetween 2 dates where
Friday is the only holiday in a week, on a form following are the fields :


StartDate - To enter the start date
EndDate - To enter the end date

WorkingDays - To obtain the result of the total working days except fridays
TotalFriday - To obtain how many friday are inbetween these two dates

Please advice code for the above solution.

Thanking you all in advance.

Regards

Irshad
 
X

XPS35

=?Utf-8?B?SXJzaGFkIEFsYW0=?= said:
I want to do a solution to find total working days inbetween 2 dates where
Friday is the only holiday in a week, on a form following are the fields :


StartDate - To enter the start date
EndDate - To enter the end date

WorkingDays - To obtain the result of the total working days except fridays
TotalFriday - To obtain how many friday are inbetween these two dates

Please advice code for the above solution.

Thanking you all in advance.

Regards

Irshad

The best way to do this is to create a function that performs the
calculation.
A function to calculate working days would look like:

Function WorkingDays(StartDate As Date, EndDate As Date) As Integer
Dim CurDate As Date
Dim DayCount As Integer

CurDate = StartDate
DayCount = 0

While CurDate <= EndDate
If DatePart("w", CurDate) <> 6 Then
DayCount = DayCount + 1
End If
CurDate = DateAdd("d", 1, CurDate)
Wend

WorkingDays = DayCount
End Function

Changing the condition of the if-statement will do the job for a
TotalFriday function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top