直接把时间转成TDateTime,TDateTime等价于double类型,就可以做加减操作。转时间,比如12:00-〉12:00:00, function ConvertStrToDateTime(sTime: string): TDateTime; var tmp: TDateTime; begin sTime := Trim(sTime)+':00'; result := StrToDateTime(sTime); end;调用 ConvertStrToDateTime('12:00')+ConvertStrToDateTime('1:10')+ConvertStrToDateTime('2:10')+...没有调试,以上只是思路。
我这里是一个数据库,现在要对这个字段求和啊,得到值后才open出来的!
oracle 中可以这样select trunc(sum(substr(ctime,1,instr(ctime,':')-1)*60+substr(ctime,instr(ctime,':')+1,length(ctime)))/60)||':'|| mod(sum(substr(ctime,1,instr(ctime,':')-1)*60+substr(ctime,instr(ctime,':')+1,length(ctime))),60) from tmp2
oracle 中可以这样在sqlserver中你做一下修改,可以写成一个函数 select trunc(sum(substr(ctime,1,instr(ctime,':')-1)*60+substr(ctime,instr(ctime,':')+1,length(ctime)))/60)||':'|| mod(sum(substr(ctime,1,instr(ctime,':')-1)*60+substr(ctime,instr(ctime,':')+1,length(ctime))),60) from tmp2
你用的是什么数据库?
function ConvertStrToDateTime(sTime: string): TDateTime;
var
tmp: TDateTime;
begin
sTime := Trim(sTime)+':00';
result := StrToDateTime(sTime);
end;调用
ConvertStrToDateTime('12:00')+ConvertStrToDateTime('1:10')+ConvertStrToDateTime('2:10')+...没有调试,以上只是思路。
select trunc(sum(substr(ctime,1,instr(ctime,':')-1)*60+substr(ctime,instr(ctime,':')+1,length(ctime)))/60)||':'|| mod(sum(substr(ctime,1,instr(ctime,':')-1)*60+substr(ctime,instr(ctime,':')+1,length(ctime))),60) from tmp2