Date Data Type

Dates and times are represented in Visual Basic using the Date data type. A Date value takes 8 bytes of memory and can represent dates and times between January 1, 1 CE to December 31, 9999. The precision of the date is up to milliseconds. Following are a few examples of declaring and initializing a date variable:

Dim d As Date = #2/2/2001#
Dim dt as Date = #January 1 1900 12:32:45 PM#

The literal date values are represented using the # delimiter. They can consist of a date or time expressed in the appropriate format for the country and time zone. Months can be expressed either as numeric values or as literal values (in the appropriate language).

Get Visual Basic® .NET by Example 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.