Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/02/2010, 11:57
LuismanueL
 
Fecha de Ingreso: mayo-2004
Ubicación: Lima-Peru
Mensajes: 72
Antigüedad: 20 años
Puntos: 0
Comparar Fechas SQL Server 2005

Hola a todos,

Tengo un problema con la comparación de fechas, estoy trabajando con VB.Net y SQL Server 2005.

Mi campo en la base de datos es del tipo DATETIME y mis atributos del VB.Net es String en el formato "dd/mm/yyyy hh:mm:ss a.m./p.m." por ejemplo -> "04/02/2010 12:51:30 p.m."

He intentado con:

1)
.....and DATEDIFF(day, " & filtro.FechaInicial & ",Fecha)>0 ")
and DATEDIFF(day, Fecha, " & filtro.FechaFinal & ")>0 ").......
2)
.....and CONVERT (VARCHAR, Fecha, 112) >= " & filtro.FechaInicial & "")
and CONVERT (VARCHAR, Fecha, 112) <= " & filtro.FechaFinal & "")......
3)
.....and Fecha >= " & CType(filtro.FechaInicial, DateTime) & "")
and Fecha <= " & CType(filtro.FechaFinal, DateTime) & "")......
4)
.....and CONVERT (DATETIME, Fecha, 112) BETWEEN CONVERT (DATETIME, " & filtro.FechaInicial & ",112 AND CONVERT (DATETIME, " & filtro.FechaFinal & ",112")

Pero NADA me genera error

Si alguien podria ayudarme sobre como realizar correctamente la comparación se lo agradecería bastante, de antemano gracias por su ayuda.