Urgent : How to calculate next X working day

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muddasirmunir
    Contributor
    • Jan 2007
    • 284

    Urgent : How to calculate next X working day

    i am using vb6. what i need is to calculate X (means any ) working day
    date skipping holidays (saturday and sunday) or (friday or saturday in some contries)

    for example:
    today is 20-06-2008 and its friday (the holidays will be saturday and sunday)
    now if i say 2 working days
    so it should give me anwer 24-06-2008
    that is adding 4 days to 20-06-2008 (2 holidays and 2 working days)

    so how to achive this task
    i have to do this as soon as possible because i had stuck in this.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey there neighbour!

    You might need to tell us a little more, it sounds like you have something working already, would you mind posting it?

    Wishing you a good luck with this one... Have you also tried searching our forum firsthand, there may have been something posted.

    Dököll

    Comment

    • muddasirmunir
      Contributor
      • Jan 2007
      • 284

      #3
      i had searched the forum but not get exactly what i want
      i want to calulate the date of upcoming x (means any ) working day
      the problem is how could i now that after let say 10 working days what is the day is


      Originally posted by Dököll
      Hey there neighbour!

      You might need to tell us a little more, it sounds like you have something working already, would you mind posting it?

      Wishing you a good luck with this one... Have you also tried searching our forum firsthand, there may have been something posted.

      Dököll

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        Try This Code:

        [code=vb]
        Dim i As Integer
        Dim TDate As Date
        Dim NDays As Integer
        NDays = 2
        i = NDays
        TDate = Date
        Do
        TDate = TDate + 1
        If Val(Format(TDat e, "W")) = 1 Or Val(Format(TDat e, "W")) = 7 Then
        'Checking For Saturday and Sunday
        Else
        i = i - 1
        End If
        Loop Until i = 0
        MsgBox "Next Working date After " & NDays & " Is " & TDate
        [/code]

        Change NDays for Number of days..

        Regards
        Veena

        Comment

        • muddasirmunir
          Contributor
          • Jan 2007
          • 284

          #5
          yes qveen its is working properly. Thanks





          Originally posted by QVeen72
          Hi,

          Try This Code:

          [code=vb]
          Dim i As Integer
          Dim TDate As Date
          Dim NDays As Integer
          NDays = 2
          i = NDays
          TDate = Date
          Do
          TDate = TDate + 1
          If Val(Format(TDat e, "W")) = 1 Or Val(Format(TDat e, "W")) = 7 Then
          'Checking For Saturday and Sunday
          Else
          i = i - 1
          End If
          Loop Until i = 0
          MsgBox "Next Working date After " & NDays & " Is " & TDate
          [/code]

          Change NDays for Number of days..

          Regards
          Veena

          Comment

          Working...