robboll (robboll (AT) hotmail (DOT) com) writes:
Quote:
I have a field with date values like: 20050714. When using SQL Server
to convert it to a Date in a View, I use the following:
CAST(MyDate as DateTime)
That works great. The problem is that some rows have the value:
00000000
When it hits one of these, I get a SQL Server Enterprise Manager Error:
Database Server: Microsoft SQL Server
Version: 08.00.0760
Runtime Error: [Microsoft][ODBC SQL Server Driver][SQL Server]The
conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value.
Is there a workaround for this? Any assistance greatly appreciated. |
You can use the isdate() function to check whether a string is a
legal date value or not.
--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp