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.YearInterval該論點的年份。

適用於

另請參閱