weekdays calculation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ConfusedMay
    New Member
    • Apr 2007
    • 57

    weekdays calculation

    Could someone please help.... ? below are my code on how to create indate and outdate.
    Code:
                              If Not IsNull(rst2.Fields("Days_Required")) Then
                                days = rst2.Fields("Days_Required")
                                
                            End If
    
                           enddate = rst2.Fields("FinalDate")
                           If days = 0 Then
                                startdate = enddate
                            Else
                               startdate = DateAdd("w", -days, enddate)
                            
                            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
    Last edited by pbmods; Feb 5 '09, 11:11 PM. Reason: Added CODE tags.
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    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.

    Comment

    • ChipR
      Recognized Expert Top Contributor
      • Jul 2008
      • 1289

      #3


      Post #3 by NeoPa

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        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.

        Comment

        Working...