有关时间的问题??在线等待!!!

luchunhua 2003-06-18 09:13:47
一个日期(2003-06-10 10:10:00),现在我要得到58小时前的日期,怎么处理????
...全文
26 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jpyc 2003-06-18
  • 打赏
  • 举报
回复
日期-58/24 刚才试过,好用。
fang3103 2003-06-18
  • 打赏
  • 举报
回复
日期-58/24
cdhuanglei 2003-06-18
  • 打赏
  • 举报
回复
TDateTime/TDate/TTime其实都是浮点数, TDateTime的整数部分表示日期,小数部分表示时间,以1899-12-30为计算点.
所以日期时间可以进行加减. 你看一下下面的注解吧,就会说明怎么作日期时间计算了:

type TDateTime = type Double;

Description

Most CLX objects represent date and time values using a TDateTime value. In Delphi, TDateTime is a type that maps to a Double. In C++, the TDateTime class corresponds to the Delphi TDateTime type.

The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.

Following are some examples of TDateTime values and their corresponding dates and times:

0 12/30/1899 12:00 am
2.75 1/1/1900 6:00 pm
-1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am
To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value if the TDateTime value is positive.
When working with negative TDateTime values, computations must handle time portion separately. The fractional part reflects the fraction of a 24-hour day without regard to the sign of the TDateTime value. For example, 6:00 am on 12/29/1899 is ?.25, not ? + 0.25, which would be ?.75. There are no TDateTime values between ? and 0.

Note: Delphi 1.0 calculated the date from year 1 instead of from 1899. To convert a Delphi 1.0 date to a TDateTime value in later versions of the Delphi language, subtract 693594.0 from the Delphi 1.0 date.
giftzhang 2003-06-18
  • 打赏
  • 举报
回复
你将取的的时间减去58小时啊,单位怎么统一啊
lovelymelon 2003-06-18
  • 打赏
  • 举报
回复
date-58/24

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧