Name

DateSerial Function — Microsoft.VisualBasic.DateAndTime

Synopsis

DateSerial(year, month, day)
year required; Integer

Number between 100 and 9999, inclusive, or a numeric expression

month required; Integer

Any numeric expression between 1 and 12 to express the month

day required; Integer

Any numeric expression between 1 and 31 to express the day

Return Value

A Date representing the date specified by the arguments

Description

Returns a Date whose value is specified by the three date components (year, month, and day).

For the function to succeed, all three components must be present, and all must be numeric values. The value returned by the function takes the short date format defined by the Regional Settings applet in the Control Panel of the client machine.

If the value of a particular element exceeds its normal limits, DateSerial adjusts the date accordingly. For example, DateSerial(96,2,31)—February 31, 1996—returns March 2, 1996.

You can specify expressions or formulas that evaluate to individual date components as parameters to DateSerial. For example, DateSerial(98,10+9,23) returns 23 March 1999. This makes it easier to use DateSerial to form dates whose individual elements are unknown at design time or that are created on the fly as a result of user input.

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.