Converting a non-standard datetime field in SQL server -
I am using SQL Server 2008 R2 I am given the data in which format mm / dd / yy : Mm: smmmm I have some examples here:
1/16/2013 10: 31: 38.000000 AM 11/12/2013 3: 42: 12.000000 Prime Minister 12/6 / 2013 2: 42: 46.000000 PM I want to convert to a datetime format so that I can work with them, but I'm having problems ... I found different sites Which is different date time formats (such as), but this format is not listed anywhere.
I have tried to convert casting and many different ways, including the following:
Select CAST (field as field) from the table; Choose from the table conversion (date time, field, 101); But I keep getting this error: "Message 241, Level 16, State 1, Line 1 conversion character string failed to change date and / or time." I think because my field is in the format, so the standard SQL can not recognize it?
Any help would be appreciated. If already covered, I'm sorry - I have spent 4 hours looking for this and other sites but I can not find the answer ...
Should not you cast it on Datetime2 type instead? Datetime is only accurate, as high as millisecond.
Comments
Post a Comment