Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回 Variant (Integer),包含代表年的整數。

語法

年 ( 日期 )

必要 日期引數 是任何 Variant、 數值運算式、 字串運算式,或是任何可以代表日期的組合。 如果 date 包含 Null,就會傳回 Null

附註: 如果 Calendar 屬性 設定是公曆,傳回的整數代表日期自變數的公曆年。 如果行事曆是回歷,則傳回的整數代表日期自變數的回歷年。 對於回歷日期,自變數數位是任何可代表公曆 1/1/100 (公曆 718 年) 8 月 2 日到 4/3/9666 的數值表達式, (公曆 9999 年 12 月 31 日) 。

查詢範例

Expression

結果​​

SELECT DateofSale, Year ([DateofSale]) AS Expr1 FROM ProductSales;

傳回“DateofSale” 字段的值,以及代表這些日期值「年份」的數位。

SELECT Year (#10/10/2018#) AS YearTest FROM ProductSales;

傳回代表 「2018/10/10」 字串 「年」的數位。 結果:2018 年。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

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

Dim MyDate, MyYear
MyDate = #February 12, 1969# ' Assign a date.
MyYear = Year(MyDate) ' MyYear contains 1969.

選擇正確的日期函數

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×