Ver Mensaje Individual
  #13 (permalink)  
Antiguo 24/04/2009, 08:12
zyon
 
Fecha de Ingreso: septiembre-2005
Mensajes: 1.289
Antigüedad: 18 años, 7 meses
Puntos: 3
Respuesta: Duda con convert a datetime

Bien, estos serian los tres priemros registros que tengo:

Código PHP:
Plantilla|Clave|No_columna|No_renglon|Valor
REGISTRO
|00.122674017418442Seccion1|1|2|15/04/2009
REGISTRO
|00.252872444992735Seccion1|1|2|15/04/2009
REGISTRO
|00.955574370206322Seccion1|1|2|15/04/2009
... 
y asi como en esos tres registros hay otros 5 mil aprox con el misma estructura en lo que es la fecha, pero si pór ejemplo ejecuto este query:

Código PHP:
select from doc_registros
    where no_renglon
='1' and no_columna='2' and isdate(valor)=and plantilla='REGISTRO'
        
and CONVERT (datetime,CONVERT(VARCHAR,valor,103),103) > CONVERT (datetime,CONVERT(VARCHAR,'14/04/2009',103),103
me devuelve solo:

Código PHP:
REGISTRO|00.122674017418442Seccion1|1|2|15/04/2009 
y enseguida me marca el error:

Código PHP:
Msg 241Level 16State 1Line 1
Conversion failed when converting datetime from character string

y si por ejemplo ejecuto:

Código PHP:
select *,CONVERT (datetime,CONVERT(VARCHAR,valor,103),103FECHAS from doc_catalogo_valores
    where no_renglon
='1' and no_columna='2' and isdate(valor)=and plantilla='REGISTRO' 
me devuelve correctamente los valores convertidos:
Código PHP:
Plantilla|Clave|No_columna|No_renglon|Valor|Fechas
REGISTRO
|00.122674017418442Seccion1|1|2|15/04/2009|2009-04-15 00:00:00.000
REGISTRO
|00.252872444992735Seccion1|1|2|15/04/2009|2009-04-15 00:00:00.000
REGISTRO
|00.955574370206322Seccion1|1|2|15/04/2009|2009-04-15 00:00:00.000 
Que hago mal, tal vez es una tonteria y no me doy cuenta
__________________
Wow! No se que decir...