Year Function (Visual Basic)
Returns an Integer value from 1 through 9999 representing the year.
Public Function Year(ByVal DateValue As DateTime) As Integer
Parameters
- DateValue
Required. Date value from which you want to extract the year.
Remarks
You can also obtain the year by calling DatePart and specifying DateInterval.Year for the Interval argument.
Example
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.
Requirements
Namespace: Microsoft.VisualBasic
Module: DateAndTime
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
See Also
Reference
Day Function (Visual Basic)
Month Function (Visual Basic)
Now Property
Weekday Function (Visual Basic)
DatePart Function (Visual Basic)
DateTime
ArgumentOutOfRangeException