Date Data Type

 <  Day Day Up  >  

The Date data type represents a moment in time. The range of the Date data type is from midnight, January 1, 1, through one second before midnight (11:59:59 PM ), December 31, 9999. The default calendar used for Date data types is the Gregorian calendar. The smallest unit of time that a Date variable can use to distinguish between two moments in time is 100 nanoseconds. It is important to remember that the Date data type does not encode the time zone of the day and time. Therefore, any calculations on Date variables that need to be sensitive to different time zones need to be handled explicitly using .NET Framework functions.

Date Literals

A date literal is a string that represents a particular day and time. A date literal begins and ends with a pound character ( # ). The date literal can be a date and a time value, a date value, or a time value. The date value is always represented in numerical month-day-year format, separated by either forward slashes ( / ) or dashes ( - ). If the date value is omitted, the default date of January 1, 1, is assumed. The time value is represented in numerical hour -minute-second format, separated by colons ( : ), followed by an AM or PM designator. If a time value is omitted, the default time of midnight is assumed. The following shows some examples of date literals.

 Dim a, b, c As Date a = #8/23/1970 3:40:32 AM# b = #8/23/1970# c = #3:40:32 AM# 

The date value must be a valid day in the Gregorian calendar; to avoid ambiguities , the year must be specified with four digits if the year being represented is between the years 1 and 99.

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net