Solved

VB .Net networkdays function Analysis toolpak support help requested.

Posted on 2004-10-13
3
903 Views
Last Modified: 2009-04-30
I am new to VB .NET and am wishing to create an application that uses the networkdays function of the analysis toolpak addin available in excel to generate number of working days between start and end dates within a table, taking into account the holidays held within a separate table.
Can you tell me if this is possible and how best to proceed?

thanks
Jase105
0
Comment
Question by:CorpSystems
  • 2
3 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12298340
Busines days between 2 dates

Function BusinessDateDiff(ByVal startDate As Date, ByVal endDate As Date,
 Optional ByVal saturdayIsHoliday As Boolean = True) As Integer
    Dim incr As Integer

    ' incr can be +1 or -1
    If startDate < endDate Then incr = 1 Else incr = -1

    Do Until startDate = endDate
        ' skip to previous or next day
        startDate = startDate.AddDays(incr)
        If startDate.DayOfWeek <> DayOfWeek.Sunday AndAlso _
            (startDate.DayOfWeek <> DayOfWeek.Saturday Or Not
saturdayIsHoliday) Then
            ' if it's a weekday add/subtract one to the result
            BusinessDateDiff += incr
        End If
    Loop
    ' when the loop is exited the function name contains the correct
result
End Function


There are different holidays for every company. I guess that you have to calculate holidays from your table and subtract it from the total. Don't forget to check if the holiday is on the week end.
0
 

Author Comment

by:CorpSystems
ID: 12299489
thanks for your idea.
Does this mean the excel networkdays function is not available as an addin to VB .Net? ie that I cannot do the equivalent
networkdays(start_date, end_Date, holidays) type call within a .NET program?
I'd rather not reinvent the wheel if there is a COM class I can reference in .NET  which contains this functionality.

Jase105
0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 500 total points
ID: 12300214
I don't think so.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now