Re: nvarchar Data type conversion to Datetime

Tech-Archive recommends: Speed Up your PC by fixing your registry



Lloyd S (LloydS@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
> I am using SQL Server. I have a field that has date data in nvarchar()
> type. I would like to convert the field and data to datetime type. I used
> convert and cast but got an error message saying there was an arithmetic
> overflow. Is there some way to fix this problem and get rid of the
> error. Is this the only way to convert the data in the field from
> nvarchar() to datetime or is there another way.

Supposedly there is data in that column which is not interpretable as
a date according to your current dateformat settings.

SELECT * FROM tbl WHERE isdate(nvarcharcol) = 0

will reveal the culprits.

Also read this: http://www.karaszi.com/SQLServer/info_datetime.asp-


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
.



Relevant Pages

  • Re: JDBC - Cant get unicode with ResultSet.getString()
    ... The column is a nvarchar and I use ResultSet.getStringto retrieve it. ... >> The data is correct in Sql Server - I viewed it there. ... >> And it is the jdbc getString() that returns it wrong, ...
    (microsoft.public.sqlserver.odbc)
  • Re: Severe performance hit with NCHAR queries
    ... Response time the first couple of times was upwards of 20+ seconds, ... When two different data types meet, SQL Server applies a strict data-type ... The data type of a string literal with a preceeding N is nvarchar. ...
    (comp.databases.ms-sqlserver)
  • Re: slow stored procedure
    ... portion of the table much a condition like WHERE EVT_UPDATED < @CutOFfDate ... WHERE (CAST(ACS_EVENT AS NVARCHAR) + ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Importing Textfiles into SQL Server 2000
    ... I have been unable to import a Text file into SQL Server 2000. ... At the end of the last field of the header column, ... nvarchar NULL, ... datetime NULL, ...
    (microsoft.public.sqlserver.server)
  • Re: Character set support
    ... I feel it is probably critical we support accents as a means to ... You need to use nvarchar. ... With varchar you can only support one code ... However, if you save data with trailing spaces, SQL Server will ...
    (comp.databases.ms-sqlserver)