.NET Date Compare: Count the amount of working days since a date?

前端 未结 7 1132
别那么骄傲
别那么骄傲 2020-12-03 08:16

What\'s the easiest way to compute the amount of working days since a date? VB.NET preferred, but C# is okay.

And by \"working days\", I mean all days excluding Satu

7条回答
  •  失恋的感觉
    2020-12-03 09:15

    Here is a sample of Steve's formula in VB without the holiday subtraction:

    Function CalcBusinessDays(ByVal DStart As Date, ByVal DEnd As Date) As Decimal
    
            Dim Days As Decimal = DateDiff(DateInterval.Day, DStart, DEnd)
            Dim Weeks As Integer = Days / 7
            Dim BusinessDays As Decimal = Days - (Weeks * 2)
            Return BusinessDays
            Days = Nothing
            Weeks = Nothing
            BusinessDays = Nothing
    
    End Function
    

提交回复
热议问题