Year Function
Returns a whole number representing the year.
Syntax
Year(date)
Arguments
Date: Required. Any expression that can represent a date.
Supported Date Formats:
MM-DD-YYYYMM/DD/YYYYDD-MM-YYYYDD/MM/YYYYYYYY-MM-DDYYYY/MM/DD
Remarks
The following example uses the Year function to obtain the year from
a specified date:
Example 1:
Dim MyDate1, MyYear1
MyDate1 = "21-01-2025"
MyYear1 = Year(MyDate1)
'Output: 2025
Example 2:
Dim MyYear2
MyYear2 = Year(Date)
'Output: If current date is 22 January 2025, then it returns 2025
Example 3:
Dim MyDate3, MyYear3
MyDate3 = DateAdd("yyyy", 5, "21/01/2020")
MyYear3 = Year(MyDate3)
'Output: 2025