Share via


DateAndTime.Month(DateTime) 方法

定義

傳回從 1 到 12 的整數值,表示當年月份。

public:
 static int Month(DateTime DateValue);
public static int Month (DateTime DateValue);
static member Month : DateTime -> int
Public Function Month (DateValue As DateTime) As Integer

參數

DateValue
DateTime

必要。 您想要從中擷取月份的 Date 值。

傳回

從 1 到 12 的整數值,表示當年月份。

範例

此範例會 Month 使用 函式,從指定的日期取得月份。 在開發環境中,日期常值會使用程式代碼的地區設定,以簡短日期格式顯示。

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

備註

您也可以呼叫 DatePart 並指定 DateInterval.Month 自變數,以取得年份的 Interval 月份。

適用於

另請參閱