Count the number of weekdays between two dates in visual basic

后端 未结 6 1231
我寻月下人不归
我寻月下人不归 2021-01-14 21:48

I\'m a SQL guy, but I need a function to calculate the number of weekdays between two dates in VB.NET. I don\'t need to worry about holidays. My attempts unfortunately have

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 22:01

    You don't need to check whether every single day between those dates is a weekday.

    If there are n days, then there are int(n / 7) complete weeks, each containing 5 weekdays, so that's 5 * int(n / 7) weekdays.

    You then need to check the days of the remaining partial week (0..6 days).

提交回复
热议问题