i have varchar col in the table which store the date in the format '22-Jul-2009 12:35:29.998'
when i use convert(datetime,qdate) or cast(calldate AS smalldatetime) in sql statement
it gives an error Syntax error converting datetime from character string.
Answer by sp_lock ·
The syntax below is correct. What version of MSSQL are you using?
DECLARE @qdate VARCHAR(25) SET @qdate = '22-Jul-2009 12:35:29.998' SELECT cast (@qdate AS SMALLDATETIME )
DECLARE @qdate VARCHAR(25) SET @qdate = '22-Jul-2009 12:35:29.998' SELECT convert (SMALLDATETIME, @qdate )
Answer by Fatherjack ·
I think you will only get answers that are the same as the answers to your other (very similar) question here http://ask.sqlservercentral.com/questions/6636/what-is-the-best-method-to-use-isdate-in-sql