Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB .Net networkdays function Analysis toolpak support help requested.

Posted on 2004-10-13
3
Medium Priority
?
935 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 1000 total points
ID: 12300214
I don't think so.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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 …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Loops Section Overview

610 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