Monday, March 12, 2012

Msg 242 when converting date from string (date in 'YYYY-MM-DD hh:mm:ss.ms' format)

MS SQL Server 2000 SP4 Spanish

It doesn't accept such values into query, although it shows them in this format.

select * from values where Dt > '2006-06-26 00:00:00.000'

returns with Msg 242,...

What am I doing wrong?

You have me baffled, because it seems to convert fine for me; however, try this in case it is a locale issue:

Code Snippet

select convert (datetime, '2006-06-26 00:00:00.000' , 121)
as explicitConversion

/*

explicitConversion
-

2006-06-26 00:00:00.000

*/

|||Explicit conversion works, but I need to get MS SQL Server to accept dates in this format (ODBC) Sad|||

Ok, found problem. My fault.

Actually ODBC format requires {ts 'YYYY-MM-DD hh:mmTongue Tieds'}, not just time string.

No comments:

Post a Comment