This documentation is archived and is not being maintained.
DateTime Methods
Visual Studio 2008
The DateTime type exposes the following members.
| Name | Description | |
|---|---|---|
|
Add | Returns a new DateTime that adds the value of the specified TimeSpan to the value of this instance. |
|
AddDays | Returns a new DateTime that adds the specified number of days to the value of this instance. |
|
AddHours | Returns a new DateTime that adds the specified number of hours to the value of this instance. |
|
AddMilliseconds | Returns a new DateTime that adds the specified number of milliseconds to the value of this instance. |
|
AddMinutes | Returns a new DateTime that adds the specified number of minutes to the value of this instance. |
|
AddMonths | Returns a new DateTime that adds the specified number of months to the value of this instance. |
|
AddSeconds | Returns a new DateTime that adds the specified number of seconds to the value of this instance. |
|
AddTicks | Returns a new DateTime that adds the specified number of ticks to the value of this instance. |
|
AddYears | Returns a new DateTime that adds the specified number of years to the value of this instance. |
|
Compare | Compares two instances of DateTime and returns an integer that indicates whether the first instance is earlier than, the same as, or later than the second instance. |
|
CompareTo | Overloaded. Compares the value of this instance to a specified DateTime value and indicates whether this instance is earlier than, the same as, or later than the specified DateTime value. |
|
DaysInMonth | Returns the number of days in the specified month and year. |
|
Equals | Overloaded. Returns a value indicating whether two DateTime objects, or a DateTime instance and another object or DateTime are equal. |
|
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
|
FromBinary | Deserializes a 64-bit binary value and recreates an original serialized DateTime object. |
|
FromFileTime | Converts the specified Windows file time to an equivalent local time. |
|
FromFileTimeUtc | Converts the specified Windows file time to an equivalent UTC time. |
|
FromOADate | Returns a DateTime equivalent to the specified OLE Automation date. |
|
GetDateTimeFormats | Overloaded. Converts the value of this instance to all the string representations supported by the standard date and time format specifiers. |
|
GetHashCode | Returns the hash code for this instance. (Overrides ValueType::GetHashCode().) |
|
GetType | Gets the type of the current instance. (Inherited from Object.) |
|
GetTypeCode | Returns the TypeCode for value type DateTime. |
|
IsDaylightSavingTime | Indicates whether this instance of DateTime is within the Daylight Saving Time range for the current time zone. |
|
IsLeapYear | Returns an indication whether the specified year is a leap year. |
|
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
|
Parse | Overloaded. Converts the specified string representation of a date and time to its DateTime equivalent. |
|
ParseExact | Overloaded. Converts the specified string representation of a date and time to its DateTime equivalent. The format of the string representation must match a specified format exactly or an exception is thrown. |
|
SpecifyKind | Creates a new DateTime object that has the same number of ticks as the specified DateTime, but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value. |
|
Subtract | Overloaded. Subtracts the specified time or duration from this instance. |
|
ToBinary | Serializes the current DateTime object to a 64-bit binary value that subsequently can be used to recreate the DateTime object. |
|
ToFileTime | Converts the value of the current DateTime object to a Windows file time. |
|
ToFileTimeUtc | Converts the value of the current DateTime object to a Windows file time. |
|
ToLocalTime | Converts the value of the current DateTime object to local time. |
|
ToLongDateString | Converts the value of the current DateTime object to its equivalent long date string representation. |
|
ToLongTimeString | Converts the value of the current DateTime object to its equivalent long time string representation. |
|
ToOADate | Converts the value of this instance to the equivalent OLE Automation date. |
|
ToShortDateString | Converts the value of the current DateTime object to its equivalent short date string representation. |
|
ToShortTimeString | Converts the value of the current DateTime object to its equivalent short time string representation. |
|
ToString | Overloaded. Converts the value of the current DateTime object to its equivalent string representation. |
|
ToUniversalTime | Converts the value of the current DateTime object to Coordinated Universal Time (UTC). |
|
TryParse | Overloaded. Converts the specified string representation of a date and time to its DateTime equivalent and returns a value that indicates whether the conversion succeeded. |
|
TryParseExact | Overloaded. Converts the specified string representation of a date and time to its DateTime equivalent. The format of the string representation must match a specified format exactly. The method returns a value that indicates whether the conversion succeeded. |
| Name | Description | |
|---|---|---|
|
ISerializable::GetObjectData | Populates a SerializationInfo object with the data needed to serialize the current DateTime object. |
|
IConvertible::ToBoolean | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToByte | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToChar | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToDateTime | Infrastructure. Returns the current DateTime object. |
|
IConvertible::ToDecimal | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToDouble | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToInt16 | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToInt32 | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToInt64 | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToSByte | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToSingle | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToType | Infrastructure. Converts the current DateTime object to an object of a specified type. |
|
IConvertible::ToUInt16 | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToUInt32 | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
|
IConvertible::ToUInt64 | Infrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException. |
Show: