Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Utilizzo di CONVERT() nella clausola WHERE per convertire varchar in data

Devi convert e Cast il Date e poi usalo nel BETWEEN clausola. Prova questo.

SELECT Con_Consult_Date
FROM Consultation
WHEREE CAST(CONVERT(CHAR(10), CONVERT(DATETIME, Con_Consult_Date, 105), 101) AS DATE) 
BETWEEN CAST(CONVERT(CHAR(10), CONVERT(DATETIME, '01-01-2013', 105), 101) AS DATE) 
AND CAST(CONVERT(CHAR(10), CONVERT(DATETIME, '31-12-2013', 105), 101) AS DATE)
GO