The DateTime and TimeSpan Types
The DateTime and TimeSpan data types also have built-in methods and properties. These class members allow you to perform three useful tasks:
- Extract a part of a DateTime (for example, just the year) or convert a TimeSpan to a specific representation (such as the total number of days or total number of minutes).
- Easily perform date and time calculations.
- Determine the current date and time and other information (such as the day of the week or whether the date occurs in a leap year).
Module Module1 Sub Main() Dim MyDate As DateTime = DateTime.Now Console.WriteLine(MyDate) MyDate = MyDate.AddDays(100) Dim DateString As String = MyDate.Year.ToString() Console.WriteLine(DateString) Console.ReadLine() End Sub End Module
30-Dec-14 1:31:19 PM 2015