By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

weekdays calculation

P: 57
Could someone please help.... ? below are my code on how to create indate and outdate.
Expand|Select|Wrap|Line Numbers
  1.                           If Not IsNull(rst2.Fields("Days_Required")) Then
  2.                             days = rst2.Fields("Days_Required")
  4.                         End If
  6.                        enddate = rst2.Fields("FinalDate")
  7.                        If days = 0 Then
  8.                             startdate = enddate
  9.                         Else
  10.                            startdate = DateAdd("w", -days, enddate)
  12.                         End If
the calculation for startdate and enddate are correct according to days required. the problem is that it calculates weekend as well. for example: enddate is 1/27/09, it required to works for 8 days, then the start date should be enddate - 8 days (exclude weekend sat and sun) = 1/16/09, but the code is giving me 1/20/09 as startdate.
Can someone help me?? I thought "w" is for weekdays only
Feb 5 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,287
Quoted from another thread:
WEEKDAY is just the numerical representation of each day (Sunday=1, Monday=2, ..., Saturday=7), but includes ALL days of the week (doesn't exclude weekends). I believe that you want WORKDAY.

Unfortunately, Workday is not a function that exists in Access. I think there was a thread not too long ago where someone wrote it though.
Feb 5 '09 #2

Expert 100+
P: 1,287

Expert 5K+
P: 8,623
Here is some code I wrote a short time ago, that will allow you to calculate workdays minus Weekends and Holidays. It may/may not be helpful to you. Refer specifically to Post #9.
Feb 8 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.