日期自动更新的考勤表,怎么设置可以自动显示农历?

日期自动更新的考勤表

    Function LunarDate(SolarDate As Date) As String
        Dim LunarMonth, LunarDay As String
        Dim i As Long, temp As Date, leapMonth As Long
        Dim LunarInfo As Variant
        LunarInfo = Array(0, 4, 0, 5, 0, 4, 0, 5, 0, 4, 0, 5, 0, 4, 0, 5) ' 闰月信息
        temp = DateSerial(1900, 1, 31)
        i = 0
        Do While temp <= SolarDate
            i = i + 1
            If i Mod 12 = 0 Then
                leapMonth = LunarInfo(i / 12 - 1)
                If leapMonth > 0 Then
                    If temp <= DateSerial(Year(temp), leapMonth, 1) Then
                        i = i + 1
                    End If
                End If
            End If
            temp = DateAdd("d", 1, temp)
        Loop
        LunarMonth = ((i - 1) Mod 12) + 1
        LunarDay = (DateDiff("d", DateSerial(Year(temp), Month(temp), 1), temp) + 1)
        LunarDate = LunarMonth & "月" & LunarDay & "日"
    End Function

利唐i人事HR社区,发布者:HR数字化研究员,转转请注明出处:https://www.ihr360.com/hrnews/20241210816.html

(0)
上一篇 2天前
下一篇 2天前

相关推荐