Year Function (Visual Basic)
Returns an Integer value from 1 through 9999 representing the year.
Public Function Year(ByVal DateValue As DateTime) As Integer
- DateValue
Required. Date value from which you want to extract 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.
Namespace: Microsoft.VisualBasic
Module: DateAndTime
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Day Function (Visual Basic)
Month Function (Visual Basic)
Now Property
Weekday Function (Visual Basic)
DatePart Function (Visual Basic)
DateTime
ArgumentOutOfRangeException