Name

Year Function — Microsoft.VisualBasic.DateAndTime

Synopsis

Year(datevalue)
datevalue required; Date or valid date expression

Any valid date expression

Return Value

Integer

Description

Returns an integer representing the year in a given date expression. If OptionStrict is off and datevalue contains Nothing, Year returns 1. For example:

Dim oDat As Object
Console.Writeline(Year(sDat))       ' Displays 1

If datevalue is a date literal (a date delimited with the # symbol), the year must contain four digits.

Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.