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 21-10-2011
Vales08 Vales08 is offline
Miembro
NULL
 
Registrado: feb 2011
Posts: 133
Poder: 14
Vales08 Va por buen camino
Realizar un bucle for con fechas!!

Hola a todos...
Hoy mi duda es concisa..

Necesito saber si se puede realizar un for con fechas o datos de tipo tDateTime..
Lo que yo quiero realizar es un for que va desde la fecha actual (Now) hasta el ultimo dia del mes (UltimoDia), donde la fecha actual se va incrementando hasta llegar a Ultimodia.

Código Delphi [-]
        var
          Proximafecha, UltimoDia, DiaActual:TdateTime;
          hoy:integer;
          dia, mes, anio: Word;

         ...
        hoy:=DayOfTheWeek(Date); // guardo el dia de la semana en el que se ubica la fecha actual
        DecodeDate(Now, anio, mes, dia);
        UltimoDia:=RecodeDate(Date, anio, mes, DaysInMonth(Now));
        // lo que realice aqui es guardar en la variable 'UltimoDia' el ultimo dia del mes

        for Proximafecha:=Now to UltimoDia do    (**)
          begin
                if  hoy=1 then   // Lunes
                  begin
                    DM.DSET_agen_turFECHA.Value:=Now; //Guardo la fecha en la tabla AGENDA
                  end;
                if  hoy=2 then   // Martes
                  begin
                    ProximaFecha:=IncDay(Date,6);
                    DM.DSET_agen_turFECHA.Value:=Proximafecha;
                  end;
                if  hoy=3 then   // Miercoles
                  begin
                    ProximaFecha:=IncDay(Date,5);
                    DM.DSET_agen_turFECHA.Value:=ProximaFecha;
                  end;
                if  hoy=4 then   // Jueves
                  begin
                    ProximaFecha:=IncDay(Date,4);
                    DM.DSET_agen_turFECHA.Value:=Proximafecha;
                  end;


Ami me salta el siguiente error al realizar el codigo en la linea (**):
Cita:
[Error] Form_registro_dia_hora.pas(1016): For loop control variable must have ordinal type
A mi entender dice que la variable para este tipo de bucle debe ser ordinal.

Trabajo con delphi 7, firebird y sql manager..

Espero su ayuda, Desde ya muchas gracias..
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
bucle para fechas de pagos chino150 Varios 5 19-05-2008 15:01:28
Bucle for de 2 en 2 douglas OOP 9 17-10-2007 15:55:53
bucle for utilizando fechas barrauda Varios 3 01-02-2007 17:28:49
bucle dentro de un bucle Cosgaya Varios 2 06-06-2005 07:05:16
¿Realizar una busqueda de fechas? judoboy SQL 4 23-05-2003 23:26:53


La franja horaria es GMT +2. Ahora son las 13:44:57.


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