VBA Year

Year Function Description

The VBA Year function returns the year for a provided date (a number from 1900 to 9999).

VBA Year Syntax

The syntax for the Year function in VBA is:

Year( date)

Parameters

date_value
A date for which the year is to be returned.

Example usage

The Year function can be used in VBA code. Let’s look at some VBA Year function examples:

Year "2015-01-01"
'Result: 2015

Year "2016-02-04 10:00"
'Result: 2016

Dim d as Date 
d = DateValue("2015-02-04 10:00")
Debug.Print Year(d)
'Result: 2015