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

SOLUCIONADO

Gracias devilguzz hice el cambio en el código y funcionó la comparacion de fechas. Dejaré a continuacion el codigo en VB.Net:

CódigoSQL
SELECT * FROM TABLA
WHERE CONVERT(varchar,fecha,112)>=@fechaInicio AND CONVERT(varchar,fecha,112)<=@fechaFin

CódigoVBNet

String fechaInicio=fechaToISOformat(dtpInicio.Value.ToSho rtDateString())
String fechaFin=fechaToISOformat(dtpFin.Value.ToShortDate String()) + " 23:59:59"

Public Function fechaToISOformat(ByVal x As DateTime) As String
Dim y As String = x.Year.ToString()
If x.Month.ToString.Length < 2 Then
y = y + "0" + x.Month.ToString
End If
If x.Day.ToString.Length < 2 Then
y = y + "0" + x.Day.ToString
End If
Return y
End Function

Public Function fechaToISOformat(ByVal x As String) As String
Return fechaToISOformat(DateTime.Parse(x))
End Function

'Gracias!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!