A collection of problems and discoveries usually related to the tech industry in some way.
Tuesday, September 18, 2007
Cast varchar to datetime
CodeGuru Forums - Convert a Varchar in a DateTime SELECT * FROM tab_val WHERE (CASE ISDATE(val) WHEN 1 THEN CAST(val As DateTime) ELSE NULL END) > CAST('2003-05-05 08:00:00.000' As DateTime) ------------------- When casting a varchar to a datetime it is critical that all the datetime pieces (such as minutes, seconds...) are in the string. Otherwise an error will be thrown.