Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #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.938
Poder: 27
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
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
rpt. manager: meses y días transcurridos entre dos fechas dandia28 Impresión 1 20-02-2008 15:56:08
Diferencia 2 Dias entre Tdatetime (delphi) y Datetime (SQL server) sinalocarlos Varios 2 10-05-2007 03:00:38
Diferencia en dias entre dos fechas. AMINOA2R Firebird e Interbase 2 15-12-2005 15:58:37
Dias y meses romansiux Varios 5 13-06-2005 17:19:12
agrupar por dias meses y años en Interbase????? mguixot Conexión con bases de datos 0 03-10-2003 19:31:08


La franja horaria es GMT +2. Ahora son las 03:52:26.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi