Gruppe
UDF
Bereich
Numerisch
Thema
Monatsberechnung in der Rentenversicherung
Problem
In der Rentenversicherung errechnen sich die Tage für Teilmonate jeweils bis zum Monatsende, Komplettmonate zählen als 30 Tage. Wie kann diese Berechnung in Excel vorgenommen werden?
Lösung
Geben Sie die nachfolgende benutzerdefinierte Funktion in ein Standardmodul ein.
StandardModule: basMain
Function RVTime(datStart As Date, datEnd As Date)
Dim iMonth, iTime As Integer
If Day(datStart) = 1 Then
iTime = 30
Else
If Year(datStart) = Year(datEnd) And _
Month(datStart) = Month(datEnd) Then
iTime = Day(DateSerial(Year(datStart), _
Month(datStart) + 1, 0)) - Day(datStart)
Else
iTime = Day(DateSerial(Year(datStart), _
Month(datStart) + 1, 0)) - Day(datStart) + 1
End If
End If
iMonth = (((Year(datEnd) - 1) - _
Year(datStart) + 1) - 1) * 12
iMonth = iMonth + (12 - Month(datStart))
iMonth = iMonth + Month(datEnd) - 1
iTime = iTime + (iMonth * 30)
If Day(datEnd) = Day(DateSerial(Year(datStart), _
Month(datStart) + 1, 0)) Then
iTime = iTime + 30
Else
iTime = iTime + Day(datEnd)
End If
RVTime = iTime
End Function