Counting Days

chriscardwell06

Registered User.
Local time
Today, 10:03
Joined
Aug 18, 2011
Messages
38
I have 2 dates that I need to count between. Easy enough just use the datediff right? Nope cause it won't count just the 5 workdays. I researched and found that the "w" in the function doesn't work the way I need it to. I found lots of code to make a module that will do it for me and they all include having a holiday table. Right now I don't need a holiday table I just want the simple dates in between. Does anyone have any suggestions?
 
You are going to have to use a function in a module. The quickest solution would be to use one of the modules you found, create the holiday table they require, but don't populate it with any data.

The most educational way would be to build your own. To do that I would suggest using the DateDiff function (http://www.techonthenet.com/access/functions/date/datediff.php) to retrieve days ("d"). You then divide that number by 7 and take just the integer part. Multiple that number by 5 for the number of days in a week. Then you work with the remainder to determine if the next days past the current date up until that remainder are weekends or not using the Weekday function (http://www.techonthenet.com/access/functions/date/weekday.php). If they are, add them to the total, if not skip them.

Give it a shot and post back here any issues you encounter or places you get stumped.
 
In the code you found that uses a holiday table, you should be able to comment out or delete the portion that checks that table. Or keep the table and just don't populate it, which will be handy if you later decide you need it.
 

Users who are viewing this thread

Back
Top Bottom