DateTime.ToOADate DateTime.ToOADate DateTime.ToOADate DateTime.ToOADate Method

定义

将此实例的值转换为等效的 OLE 自动化日期。Converts the value of this instance to the equivalent OLE Automation date.

public:
 double ToOADate();
public double ToOADate ();
member this.ToOADate : unit -> double
Public Function ToOADate () As Double

返回

一个双精度浮点数,它包含与此实例的值等效的 OLE 自动化日期。A double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance.

异常

此实例的值无法表示为 OLE 自动化日期。The value of this instance cannot be represented as an OLE Automation Date.

注解

OLE 自动化日期是以浮点数的形式实现的,其整数部分为午夜、12 1899 月30日之前或之后的天数,其小数部分表示该日除以24的时间。An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. 例如,1899年12月31日午夜1.0 表示,6 A.M.,1月 1 1900 日表示,2.25;1899年12月29日午夜表示-1.0;和6月6日上午 6 1899,表示为-1.25。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.

基础 OLE 自动化日期为1899年12月30日。The base OLE Automation Date is midnight, 30 December 1899. 最小 OLE 自动化日期为0100年1月1日午夜。The minimum OLE Automation date is midnight, 1 January 0100. 最大 OLE 自动化日期与 DateTime.MaxValue,最后一刻为9999年12月1日。The maximum OLE Automation Date is the same as DateTime.MaxValue, the last moment of 31 December 9999.

如果当前实例表示的日期晚于 January1 0100 的 MaxValue 和更早午夜,则 ToOADate 方法将引发 @no__t。The ToOADate method throws an OverflowException if the current instance represents a date that is later than MaxValue and earlier than midnight on January1, 0100. 但是,如果当前实例的值为 MinValue,则该方法返回0。However, if the value of the current instance is MinValue, the method returns 0.

有关 OLE 自动化的详细信息,请参阅MSDN libraryFor more information about OLE Automation, see the MSDN Library.

适用于

另请参阅