年份函数

返回包含表示年的整数的变量整数)。

语法

年份 (日期)

所需的 日期参数 是可以表示日期的任何 Variant数值表达式字符串表达式或任何组合。 如果 date 包含 Null,则返回 Null

注意

如果 Calendar 属性设置为 Gregorian,则返回的整数表示日期参数的公历年份。 If the calendar is Hijri, the returned integer represents the Hijri year for the date argument. For Hijri dates, the argument number is any numeric expression that can represent a date and/or time from 1/1/100 (Gregorian Aug 2, 718) through 4/3/9666 (Gregorian Dec 31, 9999).

示例

This example uses the Year function to obtain the year from a specified date. 在开发环境中,使用代码的区域设置以短日期格式显示日期文本。

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

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。