年の月を表す1から12までの整数を戻します。
構文
Month(date)
引数:
Date: 必須。日付を表現できる任意の式。
サポートされている日付フォーマット:
MM-DD-YYYYMM/DD/YYYYDD-MM-YYYYDD/MM/YYYYYYYY-MM-DDYYYY/MM/DD備考
次の例では、Month関数を使用して現在の月を戻します:
例1:
Dim MyVar MyVar = Month(Now) 'Output: If current month is January, then it returns 1
例2:
Dim MyDate, MyMonth MyDate = "21/01/2025" MyMonth = Month(MyDate) 'Output: 1 (January)
例3:
Dim MyDate1, MyMonth1
MyDate1 = DateAdd("m", 5, "21/01/2025")
MyMonth1 = Month(MyDate1)
'Output: 6 (June)
例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)