This documentation is archived and is not being maintained.

DateTime.ToOADate Method

Converts the value of this instance to the equivalent OLE Automation date.

[Visual Basic]
Public Function ToOADate() As Double
public double ToOADate();
public: double ToOADate();
public function ToOADate() : double;

Return Value

A double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance.


Exception Type Condition
OverflowException The value of this instance cannot be represented as an OLE Automation Date.


An OLE Automation date is implemented as a floating-point number whose value is the number of days from midnight, 30 December 1899. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 represented by -1.0; and 6 A.M., 29 December 1899 represented by -1.25.

Only DateTime objects with a tick value that is greater than or equal to positive or negative 31241376000000000 can be represented as an OLE Automation Date. An uninitialized DateTime, that is, an instance with a tick value of 0, is converted to the equivalent uninitialized OLE Automation Date, that is, a date with a value of 0.0 which represents midnight, 30 December 1899.

Note   The Ticks value of a DateTime is between MinValue and MaxValue.
Note   The maximum value of a DateTime is equal to the maximum value of an OLE Automation Date.

See FromOADate and the MSDN Online Libary at for more information about OLE Automation.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DateTime Structure | DateTime Members | System Namespace | Double | FromOADate