Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/08/2011, 15:33
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Sql server select que busca rango de fechas y horas

Código SQL:
Ver original
  1. CREATE TABLE #temp(
  2. fecha datetime
  3. )
  4. INSERT INTO #temp VALUES ('2011-08-08 08:30:00.000')
  5. INSERT INTO #temp VALUES ('2011-08-08 09:30:00.000')
  6. INSERT INTO #temp VALUES ('2011-08-08 10:15:00.000')
  7. INSERT INTO #temp VALUES ('2011-08-08 12:30:00.000')
  8. INSERT INTO #temp VALUES ('2011-08-09 08:45:00.000')
  9. INSERT INTO #temp VALUES ('2011-08-09 09:25:00.000')
  10. INSERT INTO #temp VALUES ('2011-08-09 20:45:00.000')
  11. INSERT INTO #temp VALUES ('2011-08-10 08:32:00.000')
  12. INSERT INTO #temp VALUES ('2011-08-10 08:49:00.000')
  13. INSERT INTO #temp VALUES ('2011-08-10 16:45:00.000')
  14.  
  15. SELECT CONVERT(datetime,fecha) AS fecha FROM #temp WHERE fecha
  16. BETWEEN CONVERT(datetime,('2011-08-08' + ' ' + '08:30:00')) AND CONVERT(datetime,('2011-08-09' + ' ' + '09:25:00'))

No te sirve asi, de los datos que pones regresaria 6 renglones no??

2011-08-08 08:30:00.000
2011-08-08 09:30:00.000
2011-08-08 10:15:00.000
2011-08-08 12:30:00.000
2011-08-09 08:45:00.000
2011-08-09 09:25:00.000


Saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me