Tema: To_date
Ver Mensaje Individual
  #4  
Antiguo 08-10-2003
Avatar de guillotmarc
guillotmarc guillotmarc is offline
Miembro
 
Registrado: may 2003
Ubicación: Huelva
Posts: 2.638
Reputación: 26
guillotmarc Va por buen camino
En efecto el CAST es la menos recomendable de todas, y la función CONVERT está limitada a la lista predeterminada.

Para convertir algo como TO_DATE('HORA:12 MINUTOS:03 SEGUNDOS:33', '"HORA:"HH" MINUTOS:"MI" SEGUNDOS:"SS'), en SQL Server tendrias que jugar con el SUBSTRING para sacar las partes de la hora, y construir una de las cadenas que si puede convertir.

SET @Variable = 'HORA:12 MINUTOS:03 SEGUNDOS:33'
select CAST(SUBSTRING(@Variable, 6, 2) + ':' + SUBSTRING(@Variable, 18, 2) + ':' SUBSTRING(@Variable, 30, 2) as DATETIME)

Sin duda es mucho más incomodo.

Saludos.
__________________
Marc Guillot (Hi ha 10 tipus de persones, els que saben binari i els que no).
Responder Con Cita