Month-Funktion

Gibt eine Ganzzahl zwischen 1 und 12 (einschließlich) zurück, die den Monat des Jahres darstellt.

Syntax

Month(date)

Argumente:

Date: Erforderlich. Ein beliebiger Ausdruck, der ein Datum darstellen kann.

Unterstützte Datumsformate:

  • MM-DD-YYYY
  • MM/DD/YYYY
  • DD-MM-YYYY
  • DD/MM/YYYY
  • YYYY-MM-DD
  • YYYY/MM/DD

Anmerkungen

Im folgenden Beispiel wird die Month-Funktion verwendet, um den aktuellen Monat zurückzugeben:

Beispiel 1:

Dim MyVar
MyVar = Month(Now)
'Output: If current month is January, then it returns 1

Beispiel 2:

Dim MyDate, MyMonth
MyDate = "21/01/2025"
MyMonth = Month(MyDate)
'Output: 1 (January)

Beispiel 3:

Dim MyDate1, MyMonth1
MyDate1 = DateAdd("m", 5, "21/01/2025") 
MyMonth1 = Month(MyDate1)                 
'Output: 6 (June)

Beispiel 4:

Dim MyDateTime2, MyMonth2
MyDateTime2 = "21/01/2025 18:45:30"   ' Date-Time value.
MyMonth2 = Month(MyDateTime2)           ' Returns the month part of the date-time value.
'Output: 1 (January)