Ver Mensaje Individual
  #2  
Antiguo 08-01-2009
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Por lo general, este tipo de problemas se resuelven usando consultas parametrizadas. Pon tu consulta así:

Código SQL [-]
select Carne, Nombre, Apellido1, Apellido2, Fecha, VisitaA, HoraEntrada
from Dentro
where HoraEntrada between :inicio and :fin
order by fecha

Los dos puntos en :inicio y :fin indican que inicio y fin son parámetros. El valor de los parámetros los asignas antes de abrir la consulta:

Código Delphi [-]
ADOQuery1.Parameters.ParamByName('inicio').Value := HoraInicio;
ADOQuery1.Parameters.ParamByName('fin').Value := HoraFin;

Aquí, HoraInicio y HoraFin deben ser valores de tipo TTime. Puedes obtenerlos a partir de una cadena de caracteres con la función StrToTime:

Código Delphi [-]
HoraInicio := StrToTime('08:00');
HoraFin := StrToTime('13:00');

Como estás trabajando con ADO, debes, además, especificar el tipo de datos de los parámetros:

Código Delphi [-]
ADOQuery1.Parameters.ParamByName('inicio').DataType := ftTime;
ADOQuery1.Parameters.ParamByName('fin').DataType := ftTime;

En resumen, tendrías algo así;

Código Delphi [-]
var
   HoraInicio, HoraFin: TTime;

begin
  
  ...

  HoraInicio := StrToTime('08:00');
  HoraFin := StrToTime('13:00');

  ADOQuery1.Parameters.ParamByName('inicio').DataType := ftTime;
  ADOQuery1.Parameters.ParamByName('fin').DataType := ftTime;

  ADOQuery1.Parameters.ParamByName('inicio').Value := HoraInicio;
  ADOQuery1.Parameters.ParamByName('fin').Value := HoraFin;

  ADOQuery1.Open;
end;

// Saludos
Responder Con Cita