This MSAccess tutorial explains how to use the Access Year function with syntax and examples.
The Microsoft Access Year function returns a four-digit year (a number from 1900 to 9999) given a date value.
The syntax for the Year function in MS Access is:
Year ( date_value )
The Year function can be used in the following versions of Microsoft Access:
Let's look at how to use the Year function in MS Access:
Year (#22/11/2003#) Result: 2003 Year (#01/01/1998#) Result: 1998
The Year function can be used in VBA code in Microsoft Access.
Dim LYear As Integer LYear = Year(#12/03/2001#)
In this example, the variable called LYear would now contain the value of 2001.
You can also use the Year function in a query in Microsoft Access.
In this query, we have used the Year function as follows:
The first Year function will extract the year value from the date 13/08/1985 and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
The results would now be displayed in a column called YearValue.
The second Year function will extract the year value from the CategoryDate field and return the results in a column called Expr2.
(scroll to see more)