DateTime.FromOADate(Double) 方法

定義

傳回等於指定 OLE Automation 日期的 DateTimeReturns a DateTime equivalent to the specified OLE Automation Date.

public:
 static DateTime FromOADate(double d);
public static DateTime FromOADate (double d);
static member FromOADate : double -> DateTime
Public Shared Function FromOADate (d As Double) As DateTime

參數

d
Double

OLE Automation 日期值。An OLE Automation Date value.

傳回

物件,表示和 d 相同的日期和時間。An object that represents the same date and time as d.

例外狀況

日期不是有效的 OLE Automation 日期值。The date is not a valid OLE Automation Date value.

備註

d 參數是雙精確度浮點數,其代表的日期是基底日期之前或之後的天數(1899年12月30日午夜)。The d parameter is a double-precision floating-point number that represents a date as the number of days before or after the base date, midnight, 30 December 1899. d 的正負號和整數部分會將日期編碼為從1899年12月30日算起的正數或負數,而 d 之小數部分的絕對值會將當天的時間編碼為從午夜算起的日位移分數。The sign and integral part of d encode the date as a positive or negative day displacement from 30 December 1899, and the absolute value of the fractional part of d encodes the time of day as a fraction of a day displacement from midnight. d 必須是介於負657435.0 到正2958465.99999999 之間的值。d must be a value between negative 657435.0 through positive 2958465.99999999.

請注意,由於日期的編碼方式,在1899年12月30日的任何時間都有兩種表示方式。Note that because of the way dates are encoded, there are two ways of representing any time of day on 30 December 1899. 例如,-0.5 和0.5 兩個都表示 1899 12 月30日上午12:00,因為基底日期的午夜或減零天的時差仍然是基底日期,而從午夜算起的半天置換則是中午。For example, -0.5 and 0.5 both mean noon on 30 December 1899 because a day displacement of plus or minus zero days from the base date is still the base date, and a half day displacement from midnight is noon.

如需 OLE Automation 的詳細資訊,請參閱 ToOADateSee ToOADate for more information on OLE Automation.

適用於

另請參閱