用formatdatetime函数,再用trunc函数!
解决方案 »
- 采用运行时包 发布exe 没有采用三方控件 都需要哪些bpl ?有个清单没 ?
- 如何将 整型数据 转换成4字节十六进制数存入字节数组
- 如何清除adoconnection的事务 Cannot start more transaction on this session
- treeview问题
- 第100次求助,不好意思,没分了,都给光了,问大家一个删除表的小问题
- 怎样使用DataModal最合理?
- ******select返回的结果问题***********
- 简单问题,请你帮忙!
- 怎样判断一个文本文件中的数据。
- 在NT4.0下的数据库使用BDE是好的,在2000下提示别名错误,这是为什么?
- 小问题:请问哪种图形控件可以显示jpg和ico等其它图象格式?
- 谁能回答这个问题,请快说,
t2 := StrToDateTime('2002-01-01 01:00:00');
n:= (t2-t1) * 86400;
var Hour, Min, Sec, MSec: Word;
begin
DecodeTime(StrToDateTime('2002-01-01 01:01:00')-StrToDateTime('2002-01-01 01:00:00'), Hour, Min, Sec, MSec);
ShowMessage(IntToStr(Hour) + '小时' + IntToStr(Min) + '分' + IntToStr(Sec) + '秒');
end;
给我答案OK?
http://www.csdn.net/expert/topic/561/561911.xml?temp=6.171817E-02
OK
但隔天呢?
tempsec, sec, min, hour: integer;
begin
tempsec:=round(24*60*60*(strtodatetime('2002-01-02 01:01:50')-strtodatetime('2002-01-01 01:02:00')));
sec:=tempsec mod 60;
min:=((tempsec-sec) div 60) mod 60;
hour:=(tempsec-sec-min*60) div 3600;
showmessage(inttostr(hour)+' '+
inttostr(min)+' '+
inttostr(sec));
end;
自己换算
var Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
DecodeDate(StrToDateTime('2002-01-01 01:01:00')-StrToDateTime('2002-01-01 01:00:00'), Year, Month, Day, );
DecodeTime(StrToDateTime('2002-01-01 01:01:00')-StrToDateTime('2002-01-01 01:00:00'), Hour, Min, Sec, MSec);
end;
Year就是你需要的年, Month就是你需要的月, Day就是你需要的日, Hour就是你需要的时, Min就是你需要的分, Sec就是你需要的秒,