卫星形式“VB 克隆”中的 TDateTime 到 ShortDateString
我试图找到一种计算方法,将 TDateTime 值 40653.6830593 转换为年、月、日、小时、分钟和秒。
当然,我确信这是可能的,但我的大脑似乎没有能力编写一个公式来从该双精度值中提取这些值。
我使用的是 Satellite Forms,一种类似 vb 的语言,但我不需要任何特定的 .NET 库来完成此操作,对吧?它应该只是一个数字计算......对吧?
感谢您的帮助!最真诚的。
乔
I am trying to find a calculation that will convert the TDateTime value 40653.6830593 into a year, a month, a day, an hour, a minute and a second.
I am sure this is possible, of course, but my brain doesn't have the power, it seems, to write a formula that will extract those values from that double.
I am using a Satellite Forms, a vb-like language, but don't expect that I would need any specific .NET libraries to do this, right? It should just be a numeric calculation... right?
Thanks for the help! Most sincerely.
Joe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基于您的“Delphi”标签...
在 Delphi 中
顺便说一句:VB 或 Delphi,哪个是?
如果你想推出自己的
来自 sysutils 单元(在双重许可证 GPL2/Borland 下发布,没有废话)
您可以在以下位置找到:http://www.koders.com/delphi/fidF6715D3FD1D4A92BA7F29F96643D8E9D11C1089F.aspx?s=hook
Based on your 'Delphi' tag...
In Delphi
BTW: VB or Delphi, which is it?
If you want to roll your own
From the sysutils unit (released under a dual license GPL2/Borland No nonsense)
Which you can find at: http://www.koders.com/delphi/fidF6715D3FD1D4A92BA7F29F96643D8E9D11C1089F.aspx?s=hook
旧版 VB 或 VBA(甚至 Excel)会将日期视为自 1899 年 12 月 30 日以来的天数,我相信 Delphi 也是如此。因此,在旧版 VB/VBA 中,您可以编写
To get April 20, 2011 4:23:36 PM。在 VB.NET 中,情况有所不同,因为 DateTime 结构默认为 0001 年 1 月 1 日。
另一位用户已经发布了 Delphi 答案。
无论如何,基本前提是您要添加天数,小数部分代表时间。因此,在此示例中,自 1899 年 12 月 30 日以来已经过去了 40653 天,还有 0.683...部分天。
Legacy VB or VBA (even Excel) would treat a Date as the number of days since 12/30/1899, and I believe the same is true for Delphi. As such, in legacy VB/VBA, you could write
To get April 20, 2011 4:23:36 PM. In VB.NET, it's different, as the DateTime struct defaults to January 1, 0001.
Another user has already posted a Delphi answer.
At any rate, the basic premise is that you're adding the number of days, with the decimal portion representing the time. So in this example, 40653 full days have passed since 12/30/1899, and 0.683... partial days.
要提取小时:
记住 1.0 = 1 天 = 24 小时,因此
希望有帮助
To extract Hours:
remember 1.0 = 1 day = 24 hours, thus
Hope that helps