Date Difference Exclude Weekends

G

Guest

In a query, how can you calculate the difference between 2 dates (Date1 and
Date2) but exclude weekends.

I am trying to return the number of working days between 2 dates.

I know DateDiff only works for all days and includes weekends.

Thanks in advance
 
G

Guest

I don't know if there is one so I wrote my own in a module and call this
instead

Function DateDiffXWE(stDate As Date, fiDate As Date) As Integer
Dim nDays As Integer

nDays = 0
While stDate < fiDate
stDate = DateAdd("d", 1, stDate)
If Weekday(stDate) > 1 And Weekday(stDate) < 7 Then
nDays = nDays + 1
End If
Wend
DateDiffXWE = nDays
End 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