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
  #1  
Antiguo 14-02-2008
CFPA86 CFPA86 is offline
Miembro
 
Registrado: sep 2003
Ubicación: Medellin (Colombia)
Posts: 119
Poder: 21
CFPA86 Va por buen camino
Diferencia de fechas

Hola, amigos foristas
Estoy usando esta funcion para buscar la diferncia de dos fechas, dicha funcion fue puesta por Dec en el club.

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 fMonth then      -------             Cual es la pregunta?
    begin
       dMonth:=fMonth+12-iMonth;
       dYear:=dYear-1;
    end
   else
    dMonth:=fMonth-iMonth;

    if fDay then  ---------                  Cual es la pregunta?
    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;

No entiendo que va en (Cual es la pregunta?) alguien me podria colaborar.
Gracias.
__________________
Siempre hay un primer momento para todo.

Última edición por dec fecha: 14-02-2008 a las 04:14:50.
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
Modificar por diferencia de fechas chipsoni SQL 4 19-12-2006 19:09:16
Diferencia de fechas noshy Varios 3 31-05-2006 18:19:24
Diferencia en dias entre dos fechas. AMINOA2R Firebird e Interbase 2 15-12-2005 15:58:37
Calcular diferencia de años entre dos fechas bismarito Firebird e Interbase 2 23-08-2003 17:13:03
Diferencia entre fechas.... seb@ OOP 1 21-08-2003 15:57:22


La franja horaria es GMT +2. Ahora son las 19:01:58.


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