Link to home
Start Free TrialLog in
Avatar of Baskar P
Baskar P

asked on

need to find the business days using the vb script

hi,

I need to find the today date is business day or not.
if today days is saturday then i want to add 16 businnes date after, if its sunday i want to add 15 date after.

kindly help on this by using vb script.

Regards,
Baskar P
Avatar of HainKurt
HainKurt
Flag of Canada image

here

dim today, nextDate
dim dw

today = Date
nextDate = today
dw = DatePart(w,today)

if dw=7 then
  nextDate = DateAdd(d,23,today) ' saturday
elseif
  dw=1 then nextDate = DateAdd(h,22,today) ' sunday
else
  nextDate = DateAdd(d,21,today) ' saturday
end if

Open in new window

Avatar of Baskar P
Baskar P

ASKER

is showing error in line 8 syntax error
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
User generated image
Hi guys,

I had a live session with author (and put the solution after that) and he only wants to find the day after 15 business days...

so, logic is very simple...

today = Date
nextDate = today
dw = DatePart("w",today)

if dw=7 then
  nextDate = DateAdd("d",23,today) ' saturday
elseif dw=1 then
  nextDate = DateAdd("h",22,today) ' sunday
else
  nextDate = DateAdd("d",21,today) ' week days
end if

Open in new window


Bill's code is almost same as this one, but it finds the day after 10 business days...
And code by Shaun's, dont know what it is all about, did not test... probably will give somethijng else, since we dont need that amount of code and logic is very simple...

So, Accepted solution should be ID: 42258139
Accepted solution should be ID: https:#a42258139
(see my previous post)