DateTime.ToOADate Method

Updated: May 2010

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

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public double ToOADate()

Return Value

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

ExceptionCondition
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 integral component is the number of days before or after 30 December 1899, and whose fractional component represents the time on that day divided by 24. 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 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25.

The base OLE Automation date is midnight, 30 December 1899. The minimum OLE Automation date is midnight, 1 January 0100. The maximum OLE Automation date is the same as DateTime.MaxValue, the last moment of 31 December 9999.

The ToOADate method throws an OverflowException if the current instance represents a date that is later than MinValue and earlier than midnight on January1, 0100. However, if the value of the current instance is MinValue, the method returns 0.

For more information about OLE Automation, see the MSDN Library.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Date

History

Reason

May 2010

Expanded the Remarks section.

Customer feedback.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft