Export (0) Print
Expand All

Year Function

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

Public Function Year(ByVal DateValue As DateTime) As Integer

Parameter

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.

Example

This 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 MyDate As Date
Dim MyYear As Integer
MyDate = #2/12/1969#   ' Assign a date.
MyYear = Year(MyDate)   ' MyYear contains 1969.

Requirements

Namespace: Microsoft.VisualBasic

Module: DateAndTime

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

See Also

Day Function | Month Function | Now Property | Weekday Function | DatePart Function | System Namespace | DateTime Structure | ArgumentOutOfRangeException Class

Show:
© 2014 Microsoft