Solved

VB .Net networkdays function Analysis toolpak support help requested.

Posted on 2004-10-13
3
924 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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