Ver Mensaje Individual
  #1  
Antiguo 21-10-2011
Vales08 Vales08 is offline
Miembro
NULL
 
Registrado: feb 2011
Posts: 133
Reputación: 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