Se voce usar o banco de dados sql server existe uma funcao
  DATEDIFF(DATAINICIAL,DATAFINA)
  eLE TE RETORNA o valor em minuto ai é so voce fazer a div e o mod que sabe 
qtas horas e minutos deu.

fabio giro <[EMAIL PROTECTED]> escreveu:
          Acho que pode ajudar. Adpate as suas necessidades.

colocar 5 edits e 1 botao:
no edit1 colocar data/hora inicial -> 01/01/2004 07:00
no edit2 colocar data/hora final -> 02/01/2004 10:00
no edit3 virá a diferenca da data/hora
no edit4 virá a diferenca de dias e horas
no edit5 virá a diferenca de horas
procedure TForm1.Button1Click(Sender: TObject);
var
dt1 : tdate;
dt2 : tdate;
hr1 : ttime;
hr2 : ttime;
dti : double;
hri : shortint;
begin
edit3.clear;
edit4.clear;
edit5.clear;
dt1 := strtodate(copy(edit1.text,1,10));
dt2 := strtodate(copy(edit2.text,1,10));
hr1 := strtotime(copy(edit1.text,12,5));
hr2 := strtotime(copy(edit2.text,12,5));
edit3.text := datetimetostr(strtodatetime(edit2.text) - 
strtodatetime(edit1.text));
if dt2 = dt1 then // mesmo dia
begin
if hr2 = hr1 then // mesma hora
edit5.text := '00:00'
else
begin // horas diferentes
edit5.text := timetostr(hr2 - hr1);
edit5.text := FormatDateTime('hh:mm',strtotime(edit5.text));
end;
end
else
begin // dia seguinte
dti := dt2 - dt1;
if dti = 1 then
begin
if hr2 < hr1 then // menos de 24 horas
begin
hri := strtoint(copy(edit3.text,12,2));
edit5.text := inttostr(hri) + copy(edit3.text,14,3);
edit5.text := FormatDateTime('hh:mm',strtotime(edit5.text));
// 24 horas edit5.text:=timetostr(StrToTime('23:59:59')+ StrToTime('00:00:01') 
- Hr1 + Hr2);
end
else
if hr2 = hr1 then // 24 horas
begin
edit4.text := floattostr(dti) + ' dia';
hri := trunc(dti * 24);
edit5.text := inttostr(hri) + ':00';
end
else
begin // entre 24 e 48 horas
edit4.text := floattostr(dti) + ' dia e ' + copy(edit3.text,12,5) + ' hora(s)';
hri := strtoint(copy(edit3.text,12,2));
hri := hri + (trunc(dti * 24));
edit5.text := inttostr(hri) + copy(edit3.text,14,3);
end
end
else
if hr2 < hr1 then // mais de 1 dia, porem menos de 48,72,... horas
begin
edit4.text := floattostr(dti - 1) + ' dia(s) e ' + copy(edit3.text,12,5) + ' 
hora(s)';
hri := strtoint(copy(edit3.text,12,2));
hri := hri + (trunc((dti - 1) * 24));
edit5.text := inttostr(hri) + copy(edit3.text,14,3);
end
else
if hr2 = hr1 then // 48,72,... horas
begin
edit4.text := floattostr(dti) + ' dias';
hri := trunc(dti * 24);
edit5.text := inttostr(hri) + ':00';
end
else
begin // mais de 1 dia, mais de 48,72,... horas
edit4.text := floattostr(dti) + ' dia(s) e ' + copy(edit3.text,12,5) + ' 
hora(s)';
hri := strtoint(copy(edit3.text,12,2));
hri := hri + (trunc((dti) * 24));
edit5.text := inttostr(hri) + copy(edit3.text,14,3);
end
end;
end;

Daniel <[EMAIL PROTECTED]> escreveu:

Aê Pessoal...Help por favor... 
Preciso saber como faço pra calcular o intervalo entre duas horas que estão
em datas diferentes... 
Exemplo... 
Qtas horas há entre 16:00:00 do dia 24/05/2007 e o 21:10:00 do dia
28/05/2007 

Ajuda por favor 

O resultado deve ser em HH:mm:ss, tem uma função no Delphi, mas não retorna
dessa forma...so retorna se foi 24, 48, 72 horas... 
Se eu pedir e a diferença for maior que 24 e menor que 48 ele retorna 24 
Por favor ajudem-me

[As partes desta mensagem que não continham texto foram removidas]

---------------------------------
Novo Yahoo! Cadê? - Experimente uma nova busca. 

[As partes desta mensagem que não continham texto foram removidas]



         

       
---------------------------------
Novo Yahoo! Cadê? - Experimente uma nova busca. 

[As partes desta mensagem que não continham texto foram removidas]

Responder a