Home  |   French  |   About  |   Search  | mvps.org

 Date/Time: How many Sundays between two dates Author(s) Michel Walsh From an initial observation made by Lyle Fairfield, here a solution to get the number of, let's say, Wednesday, between two dates: ```'************* Code Start ************* Public Function HowManyWD(FromDate As Date, _ ToDate As Date, _ WD As Long) ' No error handling actually supplied HowManyWD = DateDiff("ww", FromDate, ToDate, WD) _ - Int(WD = WeekDay(FromDate)) End Function '************* Code End *************```     In the same way, someone can easily get the number of weekdays (excluding weekends) by subtracting number of Sundays and Saturdays: ```'************* Code Start ************* Public Function HowManyWeekDay(FromDate As Date, _ ToDate As Date, _ Optional ToDateIsIncluded As Boolean = True) HowManyWeekDay = DateDiff("d", FromDate, ToDate) - _ ToDateIsIncluded - _ HowManyWD(FromDate, ToDate, vbSunday) - _ HowManyWD(FromDate, ToDate, vbSaturday) End Function '************* Code End *************```