欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

计算工作日

程序员文章站 2022-03-03 10:03:11
...
Function GetWorkdayCount(StartDay As Date, EndDay As Date) As Integer
Dim NumS As Integer, NumY As Integer
Dim WeekdayNumY(7, 6) As Integer
WeekdayNumY(1, 1) = 0
WeekdayNumY(1, 2) = 0
WeekdayNumY(1, 3) = 0
WeekdayNumY(1, 4) = 0
WeekdayNumY(1, 5) = 0
WeekdayNumY(1, 6) = 1
WeekdayNumY(2, 1) = 0
WeekdayNumY(2, 2) = 0
WeekdayNumY(2, 3) = 0
WeekdayNumY(2, 4) = 0
WeekdayNumY(2, 5) = 1
WeekdayNumY(2, 6) = 2
WeekdayNumY(3, 1) = 0
WeekdayNumY(3, 2) = 0
WeekdayNumY(3, 3) = 0
WeekdayNumY(3, 4) = 1
WeekdayNumY(3, 5) = 2
WeekdayNumY(3, 6) = 2
WeekdayNumY(4, 1) = 0
WeekdayNumY(4, 2) = 0
WeekdayNumY(4, 3) = 1
WeekdayNumY(4, 4) = 2
WeekdayNumY(4, 5) = 2
WeekdayNumY(4, 6) = 2
WeekdayNumY(5, 1) = 0
WeekdayNumY(5, 2) = 1
WeekdayNumY(5, 3) = 2
WeekdayNumY(5, 4) = 2
WeekdayNumY(5, 5) = 2
WeekdayNumY(5, 6) = 2
WeekdayNumY(6, 1) = 1
WeekdayNumY(6, 2) = 2
WeekdayNumY(6, 3) = 2
WeekdayNumY(6, 4) = 2
WeekdayNumY(6, 5) = 2
WeekdayNumY(6, 6) = 2
WeekdayNumY(7, 1) = 1
WeekdayNumY(7, 2) = 1
WeekdayNumY(7, 3) = 1
WeekdayNumY(7, 4) = 1
WeekdayNumY(7, 5) = 1
WeekdayNumY(7, 6) = 1
NumS = (EndDay - StartDay) \ 7
NumY = (EndDay - StartDay) Mod 7
If NumS = 0 And NumY = 0 Then
    GetWorkdayCount = 0
Else
    GetWorkdayCount = EndDay - StartDay - NumS * 2 - WeekdayNumY(Weekday(StartDay), NumY)
End If
End Function

上一篇: vue3 学习

下一篇: 7-15 List Leaves