DateAndTime.Year Method

Returns an Integer value from 1 through 9999 representing the year.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static int Year(
	DateTime DateValue
)

Parameters

DateValue
Type: System.DateTime

Required. Date value from which you want to extract the year.

Return Value

Type: System.Int32
Returns an Integer value from 1 through 9999 representing the year.

You can also obtain the year by calling DatePart and specifying DateInterval.Year for the Interval argument.

The following example uses the Year function to obtain the year from a specified date. In the development environment, the date literal is displayed in short date format using the locale settings of your code.

Dim thisDate As Date 
Dim thisYear As Integer
thisDate = #2/12/1969#
thisYear = Year(thisDate)
' thisYear now contains 1969.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft