VB.NET How many weekdays between two dates

Posted by SteveHardie | On: May 02 2010

Here is a quick way to find out how many times a particular day of the week occurs between two dates.
For example, how many sundays between two dates.

    Protected Function findWeekDays(ByVal startDate As Date, ByVal endDate As Date, ByVal DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek) As Integer
        Dim Resp As Integer
        Resp = DateDiff("ww", startDate, endDate, DayOfWeek)
        If Weekday(startDate) = DayOfWeek Then Resp += 1
        Return Resp
    End Function


  1. Alex says:

    Thanks! I found this in C# but no one had a VB version. Worked great in Reporting Services. You saved me a call to the database.

  2. Ajai Pillai says:

    Excellent – just what I wanted – Good one. Cheers

Leave a comment