两个字段DATE1,DATE2查找出相应的记录,把DATE1-DATE2=COLUMN13但是要求结果为 : 17:00-09:30 计算出结果为8
17:00-09:00 计算出结果为8
17:30-09:00 计算出结果为9
程序代码应该怎么写?我的做法
query1.fieldvalues['column'];:=inttostr(round(strtotime(query1.fieldvalues['date1'])-strtotime(query1.fieldvalues['date2']))*24) 怎么每次结果都是0,我都晕了!谢谢各位指教!
17:00-09:00 计算出结果为8
17:30-09:00 计算出结果为9
程序代码应该怎么写?我的做法
query1.fieldvalues['column'];:=inttostr(round(strtotime(query1.fieldvalues['date1'])-strtotime(query1.fieldvalues['date2']))*24) 怎么每次结果都是0,我都晕了!谢谢各位指教!
var i,j:integer;
a,b:integer;
begin
a:=0;
b:=0;for i:=1 to length(s) do
begin
if s[i]<>':' then
a:=a*10+strtoint(s[i])
else
break;
end;for j:=1 to length(s) do
begin
if s[j]=':' then
b:=strtoint(s[j+2])+strtoint(s[j+1])*10;
end;shijian:=b+a*60; //返回分钟数
end;
SetRoundMode(rmNearest); //设定round函数舍入规则
query1.fieldvalues['column'];=inttostr(round((strtotime(query1.fieldvalues['date1'])-strtotime(query1.fieldvalues['date2']))*24)) //应该在round函数后加一对括号
'2004-9-1 18:00:00' is not a valid integer value
试了几个明天都不能转为INT,应该怎么做才好
这样的情况应该用STRTODATETIME,不能用STRTOTIME!我在ORACLE测试时是用ROUND(STRTOTIME('18:00','HH:MI')-STRTOTIME('09:30'),'HH:MI')测试通过的,所以以为用STRTOTIME是可以的,可能在DELPHI里面不行