1) Recuperas la fecha actual con
Date.
2) Pasas la otra fecha a TDate con
StrToDateTime.
3) Utilizas esta rutina que te he escrito:
Código Delphi
[-]procedure DateDif(Date1, Date2: TDate; var Years, Months, Days: Integer);
var a1, a2, m1, m2,d1,d2: Word;
inter: TDate;
b: Boolean;
label c1, c2;
begin
b := False;
if Date1 > Date2 then
begin
Inter := Date1;
Date1 := Date2;
Date2 := Inter;
b := True;
end;
Years:=0;
Months:=0;
Days:=0;
decodedate(Date1, a1, m1, d1);
decodedate(Date2, a2, m2, d2);
c1:
if d1then
begin
while d1do
begin
inc(Days);
inc(d1);
end;
end
else if d1>d2 then
begin
while d1do
begin
inc(Days);
inc(d1);
end;
d1:=0;
inc(m1);
if m1=13 then
begin
m1:=1;
inc(a1);
end;
goto c1;
end;
c2:
if m1then
begin
while m1do
begin
inc(Months);
inc(m1);
end;
end
else if m1>m2 then
begin
while m1<13 do
begin
inc(Months);
inc(m1);
end;
m1:=1;
inc(a1);
goto c2;
end;
if a1then
while a1do
begin
inc(Years);
inc(a1);
end;
if b = True then
begin
Years := -Years;
Months := -Months;
Days := -Days;
end;
end;
Que tiene como entradas los valores Date1 y Date2 con ambas fechas y devuelve en las variables Years, Months y Days los Años, Meses y Días respectivamente. Saludos.