Access VBADiscuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I'm trying to calculate workdays(Excluding saturday and sunday) between 2 dates using access VBA but have not been able to do it.Can anyone help me out or point me to the piece of code for doing this.
i found the solution code for counting workdays between 2 dates:
Dim dif As Integer
Dim i As Integer
Dim dCount As Integer
StartDate = "01/05/2004"
enddate = "01/15/2005" '
dCount = 1
dif = DateDiff("d", Startdate, enddate, vbMonday, vbFirstJan1)
For i = 1 To dif
midTemp = DateAdd("d", i, Startdate)
If Weekday(midTemp, vbMonday) < 6 Then
dCount = dCount + 1
Interestingly DateDiff("w", Start Date, End Date) returns the number of weeks between the two dates as opposed to what the normal behavior would be to count the workdays skipping over the weekends.