世纪位日期计算

Public Shared Function GetCenturyDate(ByVal sDate As Date) As Integer
        Dim one As Date
        Dim oDay As Date
        one = DateAdd(DateInterval.Month, -(Month(sDate) - 1), sDate)
        oDay = DateAdd(DateInterval.Day, -one.Day + 1, one)

        Dim diff As Long
        diff = DateDiff(DateInterval.Day, oDay, sDate)
        '不满三位补0
        diff = CreateString(diff, "0", 3)

        Dim curyear As String
        curyear = Mid(sDate.Year.ToString, 3, 4)
        '1代表21世纪,如果到下世纪的要改成2,此程序方可用

        Return Integer.Parse("1" & curyear & diff.ToString)

    End Function

原文地址:https://www.cnblogs.com/Anders888/p/3147267.html