Ver Mensaje Individual
  #4  
Antiguo 29-07-2010
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Reputación: 26
delphi.com.ar Va por buen camino
Después de responder, me di cuenta que la funcion DAYS360 / DIAS360 no cuenta simplemente meses de 30 días, sino que es algo mas complejo:

http://office.microsoft.com/en-us/ex...005209047.aspx


Encontre en la web este código en VB: http://www.experts-exchange.com/Data..._24634023.html
Y lo traduje a esto SIN PROBARLO:

Código Delphi [-]
function Days360(const ANow, AThen: TDateTime; Method: boolean): Integer;
var
  dStartDate,
  dEndDate: TDateTime;
  wStartDay,
  wStartMonth,
  wStartYear,
  wEndDay: Word;
  FebruaryAdjustment: Integer;
begin
  { Local copy }
  dStartDate := ANow;
  dEndDate := AThen;

  DecodeDate(dStartDate, wStartYear, wStartMonth, wStartDay);
  wEndDay := DayOf(dEndDate);

  if not Method Then
  begin
    { U.S. (NASD) method.
      If the starting date is the 31st of a month, it becomes equal to the 30th of the same month.
      If the ending date is the 31st of a month and the starting date is earlier than the 30th of a month,
      the ending date becomes equal to the 1st of the next month;
      otherwise the ending date becomes equal to the 30th of the same month.
    }

    if wStartDay > 30 then
      dStartDate := dStartDate - 1;

    if (wEndDay = 31) and (wStartDay < 30) then
      dEndDate := dEndDate + 1
    else
    if(wEndDay = 31) and (wStartDay >= 30) then
      dEndDate := dEndDate - 1;

    // adjust for February
    if (wStartMonth = 2) and (wStartDay = DaysInAMonth(wStartYear, wStartMonth)) then
      FebruaryAdjustment := 30 - wStartDay // Last day of February (either 28 or 29)
    else
      FebruaryAdjustment := 0;

  end else
  begin
    {
     European method.
     Starting dates and ending dates that occur on the 31st of a month become
     equal to the 30th of the same month.
    }

    if wStartDay > 30 Then
      dStartDate := dStartDate - 1;

    if wEndDay > 30 Then
      dEndDate := dEndDate - 1;

    FebruaryAdjustment := 0;
  end;

  Result := (MonthsBetween(dStartDate, dEndDate) * 30) + (wStartDay - wStartDay) - FebruaryAdjustment;
end;
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita