Esta es una pequeña función para poder saber la diferencia en años, meses y dias transcurridos entre dos fechas.
Código Delphi
[-]
function DifDate(FechaInicio, FechaTermino: TDateTime): String;
Var
fYear,fMonth,fDay,iYear,iMonth,iDay,dYear,dMonth,dDay: Integer;
begin
fYear :=Year(FechaTermino);
fMonth:=Month(FechaTermino);
fDay :=Day(FechaTermino);
iYear :=Year(FechaInicio);
iMonth:=Month(FechaInicio);
iDay :=Day(FechaInicio);
dYear:=fYear-iYear;
if fMonththen
begin
dMonth:=fMonth+12-iMonth;
dYear:=dYear-1;
end
else
dMonth:=fMonth-iMonth;
if fDaythen
begin
dMonth:=dMonth-1;
if (fMonth-1=1) or (fMonth-1=3) or (fMonth-1=5) or (fMonth-1=7) then
fDay:=fDay+31
else
if (fMonth-1=8) or (fMonth-1=10) or (fMonth-1=12) or (fMonth-1=0) then
fDay:=fDay+31
else
if (fMonth-1=4) or (fMonth-1=6) or (fMonth-1=9) or (fMonth-1=11) then
fDay:=fDay+30
else
fDay:=fDay+28;
end;
if dMonth<0 then
begin
dYear:=dYear-1;
dMonth:=11;
end;
dDay:=fDay-iDay;
Result:=IntToStr(dYear)+'/'+IntToStr(dMonth)+'/'+IntToStr(dDay);
end;