1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)

Problemstellung:

Für 32Bit und 64Bit Office Versionen

Wie kann ich aus einem Datum die Anzahl der Tage des Monats ermitteln?

Public Function DaysInMonth(dateDatum As Date) As Integer
  If VarType(dateDatum) <> 7 Then
    DaysInMonth = Null
  Else
    DaysInMonth = DateSerial(Year(dateDatum), Month(dateDatum) + 1, 1) - _
                  DateSerial(Year(dateDatum), Month(dateDatum), 1)
  End If
End Function

Aufruf:

Dim x As Integer
x =DaysInMonth(#02.04.2004#)

Das Ergebniswäre x = 30

 

Ähnliche Artikel