DateAndTime.Year(DateTime) メソッド

定義

年を表す 1 から 9999 までの整数値を返します。

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

パラメーター

DateValue
DateTime

必須。 年を抽出する Date 値。

返品

年を表す 1 から 9999 までの整数値。

次の例では、 Year 関数を使用して、指定した日付から年を取得します。 開発環境では、日付リテラルはコードのロケール設定を使用して、短い日付の書式設定で表示されます。

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

注釈

DatePartを呼び出し、DateInterval.Year引数にIntervalを指定することで、年を取得することもできます。

適用対象

こちらもご覧ください