Converting varchar to datetime - Uri Dimant |
21-Feb-08 05:56:28
|
Hi
Add ISDATE(col)=1 in WHERE condition. If it does not help, please post
sample data to be tested |
 |
| |
Converting varchar to datetime - Daniel Crichton |
21-Feb-08 06:19:59
|
Prabha wrote on Thu, 21 Feb 2008 02:22:01 -0800:
What are your regional settings? Do all the rows have a valid date?
Could be that either the regional settings are causing the date conversion
to read them as MM/DD/YYYY (which will break on any day over 12), or you've
got invalid dates in the column. You might have better luck first using
SUBSTRING to split the dates up and reformat them as YYYYMMDD format which
is non-ambiguous.
--
Dan |
 |
| |
Converting varchar to datetime - Tibor Karaszi |
21-Feb-08 06:49:26
|
Use CONVERT instead of CAST and specify a third format code that matches the string format of your
data. The format codes are documented in Books Online, CONVERT.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi |
 |
| |
Converting varchar to datetime - Plamen Ratchev |
21-Feb-08 10:08:55
|
Style 103 should do it fine:
SELECT CONVERT(DATETIME, dt, 103)
FROM (SELECT '22/01/2008' UNION
SELECT '25/01/2008' UNION
SELECT NULL) AS D(dt)
HTH,
Plamen Ratchev
http://www.SQLStudio.com |
 |
| |
Converting varchar to datetime - Madhivanan |
23-Feb-08 03:42:21
|
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/09/24/handle-isdate-wi=
th-care.aspx |
 |
| |