Datediff - week days only

  • Thread starter Thread starter Dennis
  • Start date Start date
Here's a "brute-force" function (found in another newsgroup) for doing what
you seek:

Public Function NumberOfWeekDays(datStart As Date, datEnd As Date) As Long
Dim lngNumber As Long, lngTotalDays As Long, lngCount As Long
lngTotalDays = datEnd - datStart
lngNumber = 0
For lngCount = 1 To lngTotalDays
If DatePart("w", datStart + lngCount, vbMonday) < 6 Then lngNumber =
lngNumber + 1
Next lngCount
NumberOfWeekDays = lngNumber
End Function
 
the easy way is :

temp = datediff("w", Date1, Date2)

the "w" argument means weekdays. Look at the help for DateDiff, its
very useful.
 
Oops... I doubt it. Have you tested this?
DateDiff("w",#12/31/2003#,Date()) = 2
I don't think that is what the OP was looking for.
 
Back
Top