Month 関数 (Visual Basic)

更新 : 2007 年 11 月

月を表す 1 ~ 12 の整数型 (Integer) の値を返します。

Public Function Month(ByVal DateValue As DateTime) As Integer

パラメータ

  • DateValue
    必ず指定します。月を抽出する日付型 (Date) の値です。

解説

DatePart を呼び出し、Interval 引数に DateInterval.Month を指定することによっても月を取得できます。

使用例

次の例は、Month 関数を使って、指定された日付の "月" で表される部分を取得します。開発環境では、日付リテラルは、コード記述時のロケールで設定されている短い日付の形式で表示されます。

Dim thisDate As Date
Dim thisMonth As Integer
thisDate = #2/12/1969#
thisMonth = Month(thisDate)
' thisMonth now contains 2.

必要条件

名前空間 : Microsoft.VisualBasic

モジュール : DateAndTime

アセンブリ : Visual Basic ランタイム ライブラリ (Microsoft.VisualBasic.dll)

参照

参照

Day 関数 (Visual Basic)

Now プロパティ

Weekday 関数 (Visual Basic)

Year 関数 (Visual Basic)

DatePart 関数 (Visual Basic)

System

DateTime

ArgumentException

ArgumentOutOfRangeException