Adding work days to start date to get an end date (1 Viewer)

mcdhappy80

Registered User.
Local time
Today, 20:43
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?
 

Mr. B

"Doctor Access"
Local time
Today, 13:43
Joined
May 20, 2009
Messages
1,932
Your welcome. Good luck with your project.
 

mcdhappy80

Registered User.
Local time
Today, 20:43
Joined
Jun 22, 2009
Messages
347
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:43
Joined
May 7, 2009
Messages
19,246
It will take time to review the code.
 

Minty

AWF VIP
Local time
Today, 19:43
Joined
Jul 26, 2013
Messages
10,374
Wow arenlgp, that's dedication to the cause - it's a 8 year old thread!
 

jco23

Registered User.
Local time
Today, 14:43
Joined
Jun 2, 2015
Messages
48
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:43
Joined
May 7, 2009
Messages
19,246
You see Ms.Minty, I'm not crazy after all!
 

Users who are viewing this thread

Top Bottom