Datediff - week days only

K

Ken Snell

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
 
H

Howhiareu

the easy way is :

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

the "w" argument means weekdays. Look at the help for DateDiff, its
very useful.
 
D

Duane Hookom

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.
 
Top