Ver Mensaje Individual
  #5  
Antiguo 09-11-2017
wilcg wilcg is offline
Miembro
 
Registrado: abr 2014
Posts: 107
Reputación: 10
wilcg Va por buen camino
Hola webmasterplc, prueba con esta función.

Código Delphi [-]
function ObAAMMDD( tFInicio : TDate; tFFin : TDate ) : string;
var
  anos, meses, dias, m : Integer;
begin
  anos := YearOf (tFFin) - YearOf (tFInicio);
  if MonthOf (tFInicio) > MonthOf (tFFin) then
    anos := anos - 1;
  if MonthOf (tFFin) < MonthOf (tFInicio) then
    meses := 12 - MonthOf (tFInicio) + MonthOf (tFFin)
  else
    meses := MonthOf (tFFin) - MonthOf (tFInicio);
  if DayOf (tFFin) < DayOf (tFInicio) then
  begin
    meses := meses - 1;
    if MonthOf (tFFin) = MonthOf (tFInicio) then
    begin
      anos := anos - 1;
      meses := 11;
    end;
  end;
  dias := DayOf (tFFin) - DayOf (tFInicio);
  if dias < 0 then
  begin
    m := MonthOf (tFFin) - 1;
    if m = 0 then
      m := 12;
    case m of
      1, 3, 5, 7, 8, 10, 12 : dias := 31 + dias;
      4, 6, 9, 11 : dias := 30 + dias;
      2 :
      begin
        if ((YearOf(tFFin) mod 4 = 0) and
            (YearOf(tFFin) mod 100 <> 0))
            or (YearOf(tFFin) mod 400 = 0) then
          dias := 29 + dias
        else
          dias := 28 + dias;
      end;
    end;
  end;
  result := IntToStr (anos) + ' años, ' +
      IntToStr (meses) + ' meses, ' +
      IntToStr (dias) + ' días';

  {
     ObAAMMDD( tFInicio, tFFin );
  }
end;

Código Delphi [-]
ObAAMMDD( FechaInicio, FechaFin );
Responder Con Cita