Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Excel's NETWORKDAYS function within Access 97

Status
Not open for further replies.

Cads

Technical User
Jan 17, 2000
40
GB
Does anyone know of a routine that can work like Excel's Networkdays function which will give all the working days between two dates, with public holidays being taken into account? <br><br>I've tried (and tried!) to get Networkdays to work within Access 97's VBA but it won't recognise the function (something to do with the fact that Networkdays is in the Analysis Toolpacks).&nbsp;&nbsp;I probably can develop a routine myself but why re-invent when Excel has a perfectly good function already and Office 97 is supposed to be all about integration?(!)<br><br> <p>Steve House<br><a href=mailto:shouse@icaew.co.uk>shouse@icaew.co.uk</a><br><a href= Inst of Chartered Accts of England & Wales</a><br>
 
the DateAdd function might do want you want.<br>------------------<br>This example takes a date and, using the DateAdd function, displays a corresponding date a specified number of months in the future. <br><br>Dim FirstDate As Date ' Declare variables.<br>Dim IntervalType As String<br>Dim Number As Integer<br>Dim Msg<br>IntervalType = &quot;m&quot; ' &quot;m&quot; specifies months as interval.<br>FirstDate = InputBox(&quot;Enter a date&quot;)<br>Number = InputBox(&quot;Enter number of months to add&quot;)<br>Msg = &quot;New date: &quot; & DateAdd(IntervalType, Number, FirstDate)<br>MsgBox Msg<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Cads,<br>i ahve to calculate business days (Networkdays) in Access as well, i couldn't find any formula or command that did this directly for me. so i came up with the following code (at least you won't have to reinvent it, if you haven't already).<br><br>i have an unbound field with this control source:<b><br>=IIf(Weekday([BeginDate])&gt;Weekday([EndDate]),DateDiff(&quot;w&quot;,[BeginDate],[EndDate])*5+5-(Weekday([BeginDate])-Weekday([EndDate])),DateDiff(&quot;w&quot;,[BeginDate],[EndDate])*5+(Weekday([EndDate])-Weekday([BeginDate])))</b><br><br>BeginDate is the name of the field of the first date.<br>EndDate is the name of the field of the last date <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top