The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills. This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp). SYMPTOMSWhen you use the "w" Weekday option to calculate the number of weekdays between two dates, the DateDiff() function returns the number of weeks, not the number of work days. The "w" option is supposed to work the same way as "d" for DateDiff(). It is provided as an option for compatibility with the DatePart() function. RESOLUTION
If you are using the DateDiff() function to return the number of days, substitute "d" for "w". You can use the Visual Basic code in this article to return the number of work days rather than the number of days.
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspThe following code provides a function, DateDiffW(), that calculates the number of work days between two dates:
How to Use the DateDiffW() FunctionUse the DateDiffW() function wherever you would use DateDiff(). Instead of
use the following:
NOTE: This function returns the days UP TO the ending date, not UP TO and INCLUDING the ending date.
Steps to Test the DateDiffW() FunctionIn the Immediate Window, type the following line, and then press ENTER:
Note that 10 is returned, the number of work days.
MORE INFORMATIONSteps to Reproduce BehaviorIn the Immediate Window, type the following line, and then press ENTER:
Note that 2 is returned (the number of weeks), not 14 (the number of days)
or 10 (the number of work days).
REFERENCESFor more information about the DateDiff function, click Microsoft Access Help on the
Help menu, type "DateDiff Function" in the Office Assistant or the Answer Wizard,
and then click Search to view the topic. Additional query words: dates work day diff part prb
Keywords : kbprg kbdta |
Last Reviewed: July 6, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |