Solved

VB .Net networkdays function Analysis toolpak support help requested.

Posted on 2004-10-13
3
897 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

9 Experts available now in Live!

Get 1:1 Help Now