1. hi all,
i have a requirement in my project to find the number of weekdays in between any two given dates. can anyone help me with the code for that. it has to go into production within two days. i would greatly appreciate any help
thanks
Dev

2. What do you mean by the number of weekdays. If you mean just the number of Days You could use DateDiff Function.

------------------
Visual Basic Programmer
-----------------
PolComSoft
You will hear a lot about it.

3. DateDiff gives me the total number of days in between the two dates. i want the number of days excluding saturdays and sundays. i should have phrased it as business days or working days probably instead of weekdays

4. Try this:

Code:
Public Function GetBusinessDaysDiff(pStartDate As Date, pEndDate As Date) As Long
Dim lngDays As Long
Dim lngWeeks As Long
Dim intDifference As Integer

If pStartDate &gt; pEndDate Then
Else
lngDays = DateDiff("d", pStartDate, pEndDate)
lngWeeks = DateDiff("ww", pStartDate, pEndDate)
intDifference = 0
If Weekday(pStartDate) = vbSunday And _
Weekday(pEndDate) &lt;&gt; vbSunday And _
Weekday(pEndDate) &lt;&gt; vbSaturday Then
intDifference = -1
ElseIf Weekday(pStartDate) = vbSunday And _
Weekday(pEndDate) = vbSunday Then
intDifference = 0
ElseIf Weekday(pEndDate) = vbSunday Then
intDifference = 1
End If
If Weekday(pEndDate) &lt;&gt; vbSunday And Weekday(pEndDate) &lt;&gt; vbSaturday Then
intDifference = intDifference + 1
End If
GetBusinessDaysDiff = (lngDays - (lngWeeks * 2)) + intDifference
End If
End Function

Example: MsgBox GetBusinessDaysDiff Date, Date + 5

Regards,

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819

5. Thanks a lot for your code serge. i had to subtract one day from the final result to exclude the start date. thanks anyway
Dev

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•