我怎么能一个DateTime值转换为双? [英] How can I convert a DateTime value to a double?

查看:140
本文介绍了我怎么能一个DateTime值转换为双?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 DateTime 值转换为 double

double 表示一个OLE自动化日期,那么您可以使用 DateTime.ToOADate() 中。从链接的MSDN主题:


OLE自动化日期实现为浮点数,其值为从午夜起的天数,例如,1899年12月31日午夜,由1.0表示; 1900年1月1日由2.25表示;午夜,1899年12月29日由-1.0表示; 1899年12月29日上午6点00分用-1.25表示。



基本OLE自动化日期是1899年12月30日午夜。最大OLE自动化日期与MaxValue ,即9999年12月31日的最后一刻。


如果你正在谈论一些其他日期表示, code> double ,请指定...


How do I convert a DateTime value to a double?

解决方案

If, by double you mean an OLE Automation date, then you can use DateTime.ToOADate(). From the linked MSDN topic:

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 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 maximum OLE Automation Date is the same as MaxValue, the last moment of 31 December 9999.

If you're talking about some other date representation that can also be stored in a double, please specify...

这篇关于我怎么能一个DateTime值转换为双?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆