|
|
Question : Arithmetic overflow error converting expression to data type smalldatetime!!!
|
|
Hi! i have a table that has a column with dates that where stored in a decimal type field! ... i've converted that columnn to nvarchar(50) and then parsed the the dates from '20040225' to '2004-02-25' . That went ok. (the dates with the '20040225' where in a decimal type field...go figure!) ... but now ... after parsing the dates to the '2004-02-25' format, when i try to change the column from nvarchar(50) to smalldatetime i get the error: Arithmetic overflow error converting expression to data type smalldatetime.
I know this has something to do with some wrong date around somewhere. How can i find the wrong dates in my table? is there a query to do it? i know there is! ... please help!
|
Answer : Arithmetic overflow error converting expression to data type smalldatetime!!!
|
|
you should create a additional column (with datetime), and update it:
update yourtable set new_field= convert(datetime, yourfield, 120)
if that gives the same error, you need to identify the rows. I would load the field into a test table:
create table test_date_values ( id int, year_value varchar(4), month_value varchar(2), day_value varchar(2)) insert into test_date_values select id, substring(yourfield, 1,4), substring(yourfield, 6,2), substring(yourfield, 9,2) from yourtable
and how, check the validity of the dates...
|
|
|
|
|