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

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
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
  #2  
Antiguo 16-08-2010
Avatar de ingabraham
ingabraham ingabraham is offline
Miembro
 
Registrado: ago 2007
Posts: 614
Poder: 17
ingabraham Va por buen camino
como se llama esta función?
Method: boolean
que es?
que se le pasa por parametro.
__________________
Enseñar es la virtud de un sabio.
Responder Con Cita
  #3  
Antiguo 16-08-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Cita:
Empezado por ingabraham Ver Mensaje
como se llama esta función?
Method: boolean
que es?
que se le pasa por parametro.
Hola ingabraham.

El nombre de la función es Days360, como lo expuso Delphi.com.ar.

Method es un parámetro de tipo Boolean (Verdadero o Falso). Aparentemente, sirve para indicarle
a la función por que método se va a realizar el cálculo: U.S. (NASD) method ó European method



Saludos.

Última edición por ecfisa fecha: 16-08-2010 a las 22:19:19.
Responder Con Cita
Respuesta



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 16:28:29.


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