Adding work days to start date to get an end date

mcdhappy80

Registered User.
Local time
Today, 20:40
Joined
Jun 22, 2009
Messages
347
I need to create a function that will calculate which is the End Date and the arguments that will be provided are Start Date and Working Days. Now, I know that end date should be easily calculated when You add Days to Start Date but the problem here is that the user will provide Work Days which are 5 in week (excluding holidays) instead of 7 days of the week. Does anyone have idea how to do this? I was thinking of something like this to solve it:
The user provides WorkDays. I divide that value with 5, then for each value that lefts I add two days. Something like this:
WorkDays = 35; 35/5 = 7; DaysToAdd = 7 * 2 = 14; TotalDays = WorkDays+DaysToAdd (49), and the add that value to StartDate to get an EndDate.
What do You think?
 
Your welcome. Good luck with your project.
 
mcdhappy80,

Here is a link that should help:

http://www.mvps.org/access/datetime/date0012.htm

The function works perfectly for one of my two problems. The other problem is:
I need to display the date without adding that +1 day that is the next day.
I tried modifying the function dhNextWorkdayA in the part:
Code:
dhNextWorkdayA = SkipHolidaysA(adtmDates, dtmDate + 1, 1) - Ln 86, Col 47
to this:
Code:
dhNextWorkdayA = SkipHolidaysA(adtmDates, dtmDate, 1) - Ln 86, Col 47
In order to eliminate that +1 days to add, but that didn't solve my problem.
Can someone help me with this?
Thank You.
 
It will take time to review the code.
 
Wow arenlgp, that's dedication to the cause - it's a 8 year old thread!
 
It will take time to review the code.

sorry, I thought I deleted my post in time. i was able to figure it out shortly after posting.

all I had to do was duplicate the dhAddWorkDaysA function, rename it to dhsubtractWorkDaysA, and change the line "dtmTemp = dhNextWorkdayA(dtmTemp, adtmDates)" to read "dtmTemp = dhpreviousWorkdayA(dtmTemp, adtmDates)"

hope this helps others.
 
You see Ms.Minty, I'm not crazy after all!
 

Users who are viewing this thread

Back
Top Bottom