By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,514 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

Function to Move (Forwards or Backwards) Through Weekdays

Expert Mod 15k+
P: 31,660
This code is quite old and may be bettered.
If anyone feels they can produce better code for this function go ahead and PM me your effort. If I feel that it is better (More efficient & 100% accurate) then I will replace this with it.
Until then, it is at least a usable version that visitors can use when they're in need.

Expand|Select|Wrap|Line Numbers
  1. 'MoveWD moves datThis on by the intInc weekdays.
  2. Public Function MoveWD(datThis As Date, intInc As Integer) As Date
  3.     MoveWD = datThis
  4.     For intInc = intInc To Sgn(intInc) Step -Sgn(intInc)
  5.         MoveWD = MoveWD + Sgn(intInc)
  6.         Do While (Weekday(MoveWD) Mod 7) < 2
  7.             MoveWD = MoveWD + Sgn(intInc)
  8.         Loop
  9.     Next intInc
  10. End Function
Jan 21 '07 #1
Share this Article
Share on Google+