all groups > sql server odbc > february 2005 >
You're in the

sql server odbc

group:

DateTime Convert Error When Insert String (SS2K)



DateTime Convert Error When Insert String (SS2K) Cj
2/13/2005 9:42:29 AM
sql server odbc: Okay, I've got the raw data table created, and a trigger on
it, and record concatenating, but I can't get around the
datetime conversion problem. Can you see anything I'm
doing wrong on any of these?



[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error
converting datetime from character string.



From excel:

?cmd.CommandText



Insert Into tblSP100Raw (AllData, UpdateTime) VALUES('FI,
80, 72, 0.72725, 14.4, IT, 82, 53, 0.312098765432099, 10.6,
HC, 55, 27, 0.298333333333333, 5.4, CD, 86, 52,
0.385764705882353, 10.4, ID, 58, 31, 9.82758620689656E-02,
0, CS, 35, 32, 0.542222222222222, 6.4, EG, 27, 25,
0.534444444444445, 5, TC, 11, 4, 0.225, 0.8, MT, 33, 8,
0.222058823529412, 1.6, UT, 33, 23, 0.292424242424242,
4.6', Cast(38396.4088078704 as datetime))



Insert Into tblSP100Raw (AllData, UpdateTime) VALUES('FI,
80, 72, 0.72725, 14.4, IT, 82, 53, 0.312098765432099, 10.6,
HC, 55, 27, 0.298333333333333, 5.4, CD, 86, 52,
0.385764705882353, 10.4, ID, 58, 31, 9.82758620689656E-02,
0, CS, 35, 32, 0.542222222222222, 6.4, EG, 27, 25,
0.534444444444445, 5, TC, 11, 4, 0.225, 0.8, MT, 33, 8,
0.222058823529412, 1.6, UT, 33, 23, 0.292424242424242,
4.6', Cast(02-13-2005 9:48:41.241 as datetime))



Insert Into tblSP100Raw (AllData, UpdateTime) VALUES('FI,
80, 72, 0.72725, 14.4, IT, 82, 53, 0.312098765432099, 10.6,
HC, 55, 27, 0.298333333333333, 5.4, CD, 86, 52,
0.385764705882353, 10.4, ID, 58, 31, 9.82758620689656E-02,
0, CS, 35, 32, 0.542222222222222, 6.4, EG, 27, 25,
0.534444444444445, 5, TC, 11, 4, 0.225, 0.8, MT, 33, 8,
0.222058823529412, 1.6, UT, 33, 23, 0.292424242424242,
4.6', Convert(datetime,'02-13-2005 9:48:41 AM', 100))


Re: DateTime Convert Error When Insert String (SS2K) Mike Epprecht (SQL MVP)
2/13/2005 9:00:05 PM
Hi

Cast(38396.4088078704 as datetime)) is not a valid date value
Cast(02-13-2005 9:48:41.241 as datetime)) is an ambiguous date.
Convert(datetime,'02-13-2005 9:48:41 AM', 100)) is an ambiguous date.

Use the ISO date format of yyymmdd hh:mm:ss.sss as things work a lot better.

--
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

[quoted text, click to view]

AddThis Social Bookmark Button