|
|
 |
|
|
|
|
|
|
|
|
Visual Basic 2008 9.0 .NET Examples and Ebook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| The Date datatype is used to represent a timestamp.
Dates ranging from "January 1 of the year 0001" ( "Gregorian calendar" ) to "December 31 of the year 9999" and time ranging from "12:00:00 AM (midnight)" to "11:59:59.9999999 PM".
"AM" stands for "Ante Meridiem" ( morning ), "PM" stands for "Post Meridiem" ( afternoon ).
The minimum difference between two Date values is 100 nanoseconds.
The minimum value to represent with Date is "12:00:00 AM (midnight), January 1 of the year 0001". The maximum value is 100 nanoseconds before "January 1 of the year 10000". |
| Module Example1
Sub Main()
Dim someDate As Date
Console.WriteLine(someDate)
someDate = #12/31/9999 11:59:59 PM#
Console.WriteLine(someDate)
someDate = #12:00:00 AM#
Console.WriteLine(someDate)
someDate = #10/17/2007#
Console.WriteLine(someDate)
someDate = #10/17/2007 12:00:01 AM#
Console.WriteLine(someDate)
someDate = #10/17/2007 1:00:00 AM#
Console.WriteLine(someDate)
someDate = #10/17/2007 11:59:59 AM#
Console.WriteLine(someDate)
someDate = #10/17/2007 12:00:00 PM#
Console.WriteLine(someDate)
someDate = #10/17/2007 12:00:01 PM#
Console.WriteLine(someDate)
someDate = #10/17/2007 1:00:00 PM#
Console.WriteLine(someDate)
someDate = #10/17/2007 11:59:59 PM#
Console.WriteLine(someDate)
someDate = #10/18/2007#
Console.WriteLine(someDate)
Console.ReadLine()
End Sub
End Module Download Broncode |
| Output : 1/01/0001 0:00:00
31/12/9999 23:59:59
1/01/0001 0:00:00
17/10/2007 0:00:00
17/10/2007 0:00:01
17/10/2007 1:00:00
17/10/2007 11:59:59
17/10/2007 12:00:00
17/10/2007 12:00:01
17/10/2007 13:00:00
17/10/2007 23:59:59
18/10/2007 0:00:00 |
| A Date literal is formed using surrounding # symbols.
Date and time format : #M/D/YYYY H:MM:SS AM|PM# : - M stands for Month ( 1 - 12 ), preferable in 1 digit, 2 digits if necessary - D stands for Day ( 1 - 31 ), preferable in 1 digit, 2 digits if necessary - YYYY stands for Year ( 1 - 9999 ), always 4 digits - H stands for Hour ( 1 - 12 ), preferable in 1 digit, 2 digits if necessary - MM stands for Minutes ( 0 - 59 ), always 2 digits - SS stands for Seconds ( 0 - 59 ), always 2 digits
Only a date : #M/D/YYYY# : - default time is #12:00:00 AM# ( midnight )
Only a time : #H:MM:SS AM|PM# : - default date is #1/1/0001# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|