Qtd de Dias entre duas datas

Delphi

22/07/2004

Boa Noite,

preciso saber a quantidade de dias entre uma data e outra.

Como faço isso??

Desde já agradeço.....!


André Maretti

André Maretti

Curtidas 0

Respostas

Brunosh3

Brunosh3

22/07/2004

vê se isso te ajuda..

function IdadeAtual(Nasc : TDate; DataAtual: TDate ): Integer;
Var AuxIdade, Meses : String;
MesesFloat : Real;
IdadeInc, IdadeReal : Integer;
begin
AuxIdade := Format(´¬0.2f´, [(DataAtual - Nasc) / 365.6]);
Meses := FloatToStr(Frac(StrToFloat(AuxIdade)));
if AuxIdade = ´0´ then
begin
Result := 0;
Exit;
end;
if Meses[1] = ´-´ then
begin
Meses := FloatToStr(StrToFloat(Meses) * -1);
end;
Delete(Meses, 1, 2);
if Length(Meses) = 1 then
begin
Meses := Meses + ´0´;
end;
if (Meses <> ´0´) And (Meses <> ´´) then
begin
MesesFloat := Round(((365.6 * StrToInt(Meses)) / 100) / 30.47)
end
else
begin
MesesFloat := 0;
end;
if MesesFloat <> 12 then
begin
IdadeReal := Trunc(StrToFloat(AuxIdade)); // + MesesFloat;
end
else
begin
IdadeInc := Trunc(StrToFloat(AuxIdade));
Inc(IdadeInc);
IdadeReal := IdadeInc;
end;
Result := IdadeReal;
end;


GOSTEI 0
Aroldo Zanela

Aroldo Zanela

22/07/2004

Colega,

Basta efetuar uma subtração entre as duas datas. Veja o exemplo:

var DataAntiga: TDate;
Dias: Integer;
begin
DataAntiga := StrToDate(´01/01/1960´);
Dias := Trunc(Date - DataAntiga);
  ShowMessage(IntToStr(Dias));
end;



GOSTEI 0
Paulo_amorim

Paulo_amorim

22/07/2004

Olá

Lembrando que existem fucoes especiais para fazer um delta...

MonthsBetween, DaysBetween ou algo do genero

Qualquer pesquisa no forum por ´intervalo de datas´ deve retornar algo satisfatorio

Até+


GOSTEI 0
POSTAR