Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 01-07-2006
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Diferencias entre dos fechas

Esta es una pequeña función para poder saber la diferencia en años, meses y dias transcurridos entre dos fechas.

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 fMonththen
    begin
       dMonth:=fMonth+12-iMonth;
       dYear:=dYear-1;
    end
   else
    dMonth:=fMonth-iMonth;

    if fDaythen
    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;
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


La franja horaria es GMT +2. Ahora son las 00:10:49.


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