DateAndTime Class

The DateAndTime module contains the procedures and properties used in date and time operations.

System.Object
  Microsoft.VisualBasic.DateAndTime

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

[StandardModuleAttribute]
public sealed class DateAndTime

The DateAndTime type exposes the following members.

  NameDescription
Public propertyStatic memberDateStringReturns or sets a String value representing the current date according to your system.
Public propertyStatic memberNowReturns a Date value containing the current date and time according to your system.
Public propertyStatic memberTimeOfDayReturns or sets a Date value containing the current time of day according to your system.
Public propertyStatic memberTimerReturns a Double value representing the number of seconds elapsed since midnight.
Public propertyStatic memberTimeStringReturns or sets a String value representing the current time of day according to your system.
Public propertyStatic memberTodayReturns or sets a Date value containing the current date according to your system.
Top

  NameDescription
Public methodStatic memberDateAdd(DateInterval, Double, DateTime)Returns a Date value containing a date and time value to which a specified time interval has been added.
Public methodStatic memberDateAdd(String, Double, Object)Returns a Date value containing a date and time value to which a specified time interval has been added.
Public methodStatic memberDateDiff(DateInterval, DateTime, DateTime, FirstDayOfWeek, FirstWeekOfYear)Returns a Long value specifying the number of time intervals between two Date values.
Public methodStatic memberDateDiff(String, Object, Object, FirstDayOfWeek, FirstWeekOfYear)Returns a Long value specifying the number of time intervals between two Date values.
Public methodStatic memberDatePart(DateInterval, DateTime, FirstDayOfWeek, FirstWeekOfYear)Returns an Integer value containing the specified component of a given Date value.
Public methodStatic memberDatePart(String, Object, FirstDayOfWeek, FirstWeekOfYear)Returns an Integer value containing the specified component of a given Date value.
Public methodStatic memberDateSerialReturns a Date value representing a specified year, month, and day, with the time information set to midnight (00:00:00).
Public methodStatic memberDateValueReturns a Date value containing the date information represented by a string, with the time information set to midnight (00:00:00).
Public methodStatic memberDayReturns an Integer value from 1 through 31 representing the day of the month.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberHourReturns an Integer value from 0 through 23 representing the hour of the day.
Public methodStatic memberMinuteReturns an Integer value from 0 through 59 representing the minute of the hour.
Public methodStatic memberMonthReturns an Integer value from 1 through 12 representing the month of the year.
Public methodStatic memberMonthNameReturns a String value containing the name of the specified month.
Public methodStatic memberSecondReturns an Integer value from 0 through 59 representing the second of the minute.
Public methodStatic memberTimeSerialReturns a Date value representing a specified hour, minute, and second, with the date information set relative to January 1 of the year 1.
Public methodStatic memberTimeValueReturns a Date value containing the time information represented by a string, with the date information set to January 1 of the year 1.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodStatic memberWeekdayReturns an Integer value containing a number representing the day of the week.
Public methodStatic memberWeekdayNameReturns a String value containing the name of the specified weekday.
Public methodStatic memberYearReturns an Integer value from 1 through 9999 representing the year.
Top

This module supports the Visual Basic language keywords and run-time library members that get the current date or time, perform date calculations, return a date or time, set the date or time, or time the duration of a process.

This example uses the Today property to return the current system date.

Dim thisDate As Date
thisDate = Today 

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft