Converting DB date in text format to date
Posted on 2006-06-20
I have a database in which the date fields were converted to text ( I inheirited the database). Now I would like to query the database, but the dates are stuck in text format. I need to convert them so I can compare date ranges in a query.
I'm using SQL Query Analyzer to test the SQL query string, and I get this message:
Server: Msg 306, Level 16, State 1, Line 3
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Is it possible to simply cast the text dates to temporarily make them dates for query purposes?
Please provite a simple SQL query for this.