下面的代码应该输出1吧?可是输出了0!
help里说
HoursBetween reports the difference between 9:00 AM and 9:59:59 AM as 0 because the difference is one second short of an entire hour.
可是好像只对起始时间非0的有效。uses DateUtils;procedure TForm1.Button1Click(Sender: TObject);
var
dtStart, dtEnd : TDateTime;
nowDate, LastDate : TDate;
ftMax, ftMin : double;
begin
dtStart := IncHour( DateOf(now), StrToInt('0') );
dtEnd := IncHour( DateOf(now), StrToInt('1') );
ShowMessage( IntToStr(Hoursbetween(dtStart,dtEnd) ))
end;
help里说
HoursBetween reports the difference between 9:00 AM and 9:59:59 AM as 0 because the difference is one second short of an entire hour.
可是好像只对起始时间非0的有效。uses DateUtils;procedure TForm1.Button1Click(Sender: TObject);
var
dtStart, dtEnd : TDateTime;
nowDate, LastDate : TDate;
ftMax, ftMin : double;
begin
dtStart := IncHour( DateOf(now), StrToInt('0') );
dtEnd := IncHour( DateOf(now), StrToInt('1') );
ShowMessage( IntToStr(Hoursbetween(dtStart,dtEnd) ))
end;
解决方案 »
- 我新学!想创建个表!大家帮我看看!
- 请问有没有像OutLook界面的控件(高分相送,急!)
- 学习李维的《Delphi5.x分布式多层应用 电子商务篇》时,遇到一个小问题,希望大家帮帮我。看过这本书的请进!
- 请问在Delphi如何使用Word中的宏进行查询替代?
- 關于忽略異常的話題﹐請大俠幫忙﹗﹗﹗﹗
- 简单的打包问题???
- 又有一个delphi论坛成立了吔!!
- 我想拜师学艺!请高手执教!用EMail联系![email protected]如果有意为师,请留下邮件地址!
- 请问delphi的软件怎样发布??可否赐教??555。。。
- 请问在delphi程序里如何对Access2000数据库的具体时间进行查询?
- 如何使用Tquery+DBGrid访问Access数据库?这样可以使用相对路径吗?在线等待,谢谢
- 怎样用最简单的方法设置各类的输入框impname为空
var
dtStart, dtEnd : TDateTime;
begin
dtStart := now;//IncHour( now, StrToInt('0') );
dtEnd := now+strtotime('2:00:00');//IncHour( now, StrToInt('1') );
showmessage(datetimetostr(dtstart));
showmessage(datetimetostr(dtend)); ShowMessage( IntToStr(Hoursbetween(dtStart,dtEnd)))
end;你再试试这个,返回2,又对了,我更晕。差一天返回24也对了,就差1小时返回的值不对。
procedure TForm1.Button1Click(Sender: TObject);
var
dtStart, dtEnd : TDateTime;
begin
dtStart := now;//IncHour( now, StrToInt('0') );
dtEnd := now+strtotime('1:00:01');//IncHour( now, StrToInt('1') );
showmessage(datetimetostr(dtstart));
showmessage(datetimetostr(dtend)); ShowMessage( IntToStr(Hoursbetween(dtStart,dtEnd)))
end;