Excel YEAR Function

The Excel YEAR function returns the year from a specified date

Example: Excel YEAR Function

Excel YEAR Function

METHOD 1. Excel YEAR Function using hardcoded values

EXCEL

=YEAR("15/03/2017")
Result in cell C5 (2017) - in this example we are inserting the date directly into the Excel YEAR function, which returns the year component of the date.

METHOD 2. Excel YEAR Function using links

EXCEL

=YEAR(B5)
Result in cell C5 (2017) - in this example we are referencing to a cell that contains a date and the Excel YEAR function returns the year component of the date.

METHOD 3. Excel YEAR function using the Excel built-in function library with hardcoded values

EXCEL

Formulas tab > Function Library group > Date & Time > YEAR > populate the input box

=YEAR("15/03/2017")
Note: in this example we are manually populating the input box with the date from which we want to return the year component. If entering the date directly into the input box, as per this example, we need to use the double quotation marks.
Built-in Excel YEAR Function using hardocded values

METHOD 4. Excel YEAR function using the Excel built-in function library with links

EXCEL

Formulas tab > Function Library group > Date & Time > YEAR > populate the input box

=YEAR(B5)
Note: in this example we are populating the input box with a cell reference that captures the date from which we want to return the year component.
Built-in Excel YEAR Function using links

METHOD 1. Excel YEAR function using VBA with hardcoded values

VBA

Sub Excel_YEAR_Function_Using_Hardcoded_Values()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("YEAR")
'apply the Excel YEAR function
ws.Range("C5") = Year("15/03/2017")

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named YEAR.

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

METHOD 2. Excel YEAR function using VBA with links

VBA

Sub Excel_YEAR_Function_Using_Links()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("YEAR")
'apply the Excel YEAR function
ws.Range("C5") = Year(ws.Range("B5"))

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named YEAR.
Date: If using this exact VBA code, which sources the date from cell ("C5"), you will need to capture the date from which you want to extract the year in cell ("C5").

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Date: Select the date from which you want to extract the year by changing the cell reference ("C5") to any cell in the worksheet that contains the date and doesn't conflict with the formula.

Usage of the Excel YEAR function and formula syntax

EXPLANATION

DESCRIPTION
The Excel YEAR function returns the year from a specified date.
SYNTAX
=YEAR(serial_number)

ARGUMENTS
serial_number: (Required) The date from which you want to extract the year from.