Ver Mensaje Individual
  #22  
Antiguo 27-02-2007
Avatar de gluglu
[gluglu] gluglu is offline
Miembro Premium
 
Registrado: sep 2004
Ubicación: Málaga - España
Posts: 1.455
Reputación: 23
gluglu Va por buen camino
Intentaré hacerlo con un código 'genérico' para que sea más comprensible.

Ya lo adaptas a la base de datos que utilices.

Código Delphi [-]
Select FechaInicio, FechaFinal from FECHAS
where Profesor = CodigoSeleccionado
order by FechaInicio
 
First;
FechaMin := FechaInicio;
FechaMax := FechaFinal;
TotDiasTrabajados := 0;
 
while not Eof do begin
 
  if (FechaInicio <= FechaMax) and (FechaFinal >= FechaMin) then begin
    if FechaFinal > FechaMax then FechaMax := FechaFinal;
  end
  else begin
    TotDiasTrabajados := TotDiasTrabajados + (FechaMax - FechaMin);
    FechaMin := FechaInicio;
    FechaMax := FechaFinal;
  end;
 
  Next;
 
end;
 
TotDiasTrabajados := TotDiasTrabajados + (FechaMax - FechaMin);

Pruébalo. Espero sorprenderte con el resultado.

Un saludo.
__________________
Piensa siempre en positivo !
Responder Con Cita