joecre
May 8th, 2003, 10:01 AM
Hi everybody I need a little help to solve this T-SQL problem.
In my application I have a table with a column that accepts varchar value. I use this column to store value of properties with different data types (Integer, Float ,Varchar and DateTime).
When I try to use a syntax like this to retrieve information from this table I receive a SQL error
"Syntax error converting datetime from character string."
SELECT * FROM tab_val
WHERE ISDATE(val)=1 AND CAST(val As DateTime) > CAST('2003-05-05 08:00:00.000' As DateTime)
where tab_val is my table, val is the column that accepts varchar value and '2003-05-05......' is input value that is a varchar type.
Can anyone suggest me a method to perform this query ?
Actually I compare the column value and the input value as varchar but I'm not sure that is the correct method.
I would to convert the two varchar values in DateTime.
Thank you everybody
In my application I have a table with a column that accepts varchar value. I use this column to store value of properties with different data types (Integer, Float ,Varchar and DateTime).
When I try to use a syntax like this to retrieve information from this table I receive a SQL error
"Syntax error converting datetime from character string."
SELECT * FROM tab_val
WHERE ISDATE(val)=1 AND CAST(val As DateTime) > CAST('2003-05-05 08:00:00.000' As DateTime)
where tab_val is my table, val is the column that accepts varchar value and '2003-05-05......' is input value that is a varchar type.
Can anyone suggest me a method to perform this query ?
Actually I compare the column value and the input value as varchar but I'm not sure that is the correct method.
I would to convert the two varchar values in DateTime.
Thank you everybody