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

Urgent : How to calculate next X working day

100+
P: 284
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.
Jun 21 '08 #1
Share this Question
Share on Google+
4 Replies


Dököll
Expert 100+
P: 2,364
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
Jun 21 '08 #2

100+
P: 284
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


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
Jun 22 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Try This Code:

Expand|Select|Wrap|Line Numbers
  1.     Dim i As Integer
  2.     Dim TDate As Date
  3.     Dim NDays As Integer
  4.     NDays = 2
  5.     i = NDays
  6.     TDate = Date
  7.     Do
  8.         TDate = TDate + 1
  9.         If Val(Format(TDate, "W")) = 1 Or Val(Format(TDate, "W")) = 7 Then
  10.              'Checking For Saturday and Sunday
  11.         Else
  12.             i = i - 1
  13.         End If
  14.     Loop Until i = 0
  15.     MsgBox "Next Working date After " & NDays & " Is " & TDate
  16.  
Change NDays for Number of days..

Regards
Veena
Jun 22 '08 #4

100+
P: 284
yes qveen its is working properly. Thanks





Hi,

Try This Code:

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. Dim TDate As Date
  3. Dim NDays As Integer
  4. NDays = 2
  5. i = NDays
  6. TDate = Date
  7. Do
  8. TDate = TDate + 1
  9. If Val(Format(TDate, "W")) = 1 Or Val(Format(TDate, "W")) = 7 Then
  10. 'Checking For Saturday and Sunday
  11. Else
  12. i = i - 1
  13. End If
  14. Loop Until i = 0
  15. MsgBox "Next Working date After " & NDays & " Is " & TDate
  16.  
Change NDays for Number of days..

Regards
Veena
Jun 22 '08 #5

Post your reply

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