I have a database where I need to calculate the business days taken between the start date and finish date of jobs. This calculation also needs to incorporate holidays.
To get started I implemented the modules from http://msdn.microsoft.com/en-us/library/dd327646(v=office.12).aspx#Access2007CountingWorkingDays_CalculatingWorkingDays. All was working fine until I noticed a few anomalies with some of the calculations. I picked on one and tried to find the problem with it - this was Job Start 1/4/14 and Job Finish 8/4/14.
Going through the modules I noticed that the Dcount function in the Workdays() procedure was returning 4 days instead of zero. I messed around with the tables and tried assigning dates straight to the relevant variables rather than getting them from the tables in case they were stored incorrectly. I noticed that if I removed 4 certain dates from the holiday table, the calculation was correct even though these holiday dates did not fall between 2 dates passed to the procedure. I then created a new database to make sure there wasn't any issue with the way the dates were being stored but found the same problem. I have attached this database as an example including the 4 dates that cause the issue. You can change these dates around and it has different effects, for example change the years to 2011 and it works from.
I then had a search on this forum and found the following page, http://www.access-programmers.co.uk/forums/showthread.php?t=238821&highlight=Holiday.
I downloaded this database and added the dates stored in my database into this one (Job start 1/4/14, Job Finish 8/4/14, Holidays; 18/4/14, 21/4/14, 5/5/14, 26/5/14) and this also incorrectly calculates the difference. Any idea why these dates are causing problems? Any help would be greatly appreciated.
To get started I implemented the modules from http://msdn.microsoft.com/en-us/library/dd327646(v=office.12).aspx#Access2007CountingWorkingDays_CalculatingWorkingDays. All was working fine until I noticed a few anomalies with some of the calculations. I picked on one and tried to find the problem with it - this was Job Start 1/4/14 and Job Finish 8/4/14.
Going through the modules I noticed that the Dcount function in the Workdays() procedure was returning 4 days instead of zero. I messed around with the tables and tried assigning dates straight to the relevant variables rather than getting them from the tables in case they were stored incorrectly. I noticed that if I removed 4 certain dates from the holiday table, the calculation was correct even though these holiday dates did not fall between 2 dates passed to the procedure. I then created a new database to make sure there wasn't any issue with the way the dates were being stored but found the same problem. I have attached this database as an example including the 4 dates that cause the issue. You can change these dates around and it has different effects, for example change the years to 2011 and it works from.
I then had a search on this forum and found the following page, http://www.access-programmers.co.uk/forums/showthread.php?t=238821&highlight=Holiday.
I downloaded this database and added the dates stored in my database into this one (Job start 1/4/14, Job Finish 8/4/14, Holidays; 18/4/14, 21/4/14, 5/5/14, 26/5/14) and this also incorrectly calculates the difference. Any idea why these dates are causing problems? Any help would be greatly appreciated.