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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to calculate a future date

Status
Not open for further replies.

jpower69

Programmer
Feb 5, 2008
54
US
Good Morning

I have been trying to find a way to calculate a future date based upon an already existing date
being passed into a routine

My question is this

I have a date, for example 05/25/16 and I need to add 48 months plus 10 days to create this future date
basically for 10 business days, not a full days tens

I also have to check for holiday's after the future has been created

I can do this in Visual Foxpro, but where I am they are going to .net and this would be a great subroutine
for future processing

So if anyone can point me in the right direction on this greatly appreciated

Thanks in advance













 
Use the DateAdd function.

Dim CurrentDate AsDate

Dim NewDate As Date

NewDate = DateAdd(DateInterval.Month, 48, CurrentDate) 'add 48 months

Select Case NewDate.DayOfWeek
Case DayOfWeek.Saturday​
NewDate = DateAdd(DateInterval.Day, 13, NewDate) 'Add 13 days: 1 to get to Sunday, 5 for the first week, 2 for the weekend, 5 more for the next week (10 business days)​
Case DayOfWeek.Sunday​
NewDate = DateAdd(DateInterval.Day, 12, NewDate) 'Add 12 days: 5 for the first week, 2 for the weekend, 5 more for the next week​
Case Else​
NewDate = DateAdd(DateInterval.Day, 14, NewDate) 'Add 14 days: 10 business days and 4 for weekends​

End Select



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!
 
What you really need is a business-day calendar table. Every manufacturing company I've worked for has had a manufacturing-day calendar, that you can join to your table(s) and simply add to the business-days to arrive at a valid work day. No guessing for holidays or other non-work days.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top