//双精度值转时间值 DateTime dateTimeValue = DateTime.FromOADate(doubleValue); //时间值转双精度值 double doubleValue = dateTimeValue.ToOADate();; //用自定义方法将时间值转双精度值 double doubleValue = DoubleDateTime("dateTimeValue"); /// <summary> /// 输入时间字符串,返回该时间字符串对应的双精度值 /// </summary> /// <param name="DateTimeStr">需要转换的时间字符串</param> /// <returns>返回一个双精度浮点数,它包含与此实例等效的OLE自动化日期;若转换失败,返回当前时间的双精度值</returns> public static double DoubleDateTime(string DateTimeStr) { try { DateTime dt = Convert.ToDateTime(DateTimeStr); double result = dt.ToOADate(); return result; } catch { DateTime dt = Convert.ToDateTime(DateTime.Now.ToLongTimeString()); double result = dt.ToOADate(); return result; } }