troubleshooting Question

Weekdays calculation - Access/VBA 2010

Avatar of drivers
driversFlag for Canada asked on
Microsoft Access
3 Comments1 Solution1200 ViewsLast Modified:
Hi Experts
I am using weekdays function which calculates business days from a Date field
Currently it seems to be working fine for negative values but would also like to see 0 and positive values. Table screenshot shows how values to be calculated.

Public Function CountWeekDays(SLADate As Date, DevDate As Date) As Integer
 'count the number of week days between two dates    

    Dim CheckDate As Date
    CountWeekDays = 0
    CheckDate = SLADate

    Do Until CheckDate > DevDate
        If Weekday(CheckDate) <> 1 And Weekday(CheckDate) <> 7 Then
        CountWeekDays = CountWeekDays - 1
        End If
    CheckDate = CheckDate + 1

End Function

SDateCount: IIf(IsNull([Sdate]),Null,CountWeekDays(Date(),[Sdate]-1))
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros