Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working Day

Status
Not open for further replies.

besto1a

Programmer
Aug 20, 2006
41
GB
If i have a date and want to calculate what that date is +10 days including working days how do i do that?
 
This will give you the date ten days from today:

Dim d As Date

d = DateAdd(DateInterval.Day, 10, Date.Today)


Not sure what you mean by "including working days".



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
I'm assuming he only wants to count week days (mon-fri)

I'm not sure if there is a predefined function for it. But you could loop through dates and check for sat/sun.

Code:
public function AddWorkingDays(DaysToAdd as integer)
Dim StartDate as date = today

  while DaysAdded < DaysToAdd
    if startdate.dayofweek <> "Saturday" and _
       startdate.dayofweek <> "Sunday" then DaysAdded+=1
    startDate.adddays(1)
  end while  

  return StartDate
end function

*not tested


-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top