Link to home
Start Free TrialLog in
Avatar of NevSoFly
NevSoFly

asked on

need to convert string 030308 into smalldatetime

when using the below query I get the error 'Arithmetic overflow error converting expression to data type smalldatetime.'

UPDATE    tblCourseHistory
SET              Starting_Date = RIGHT(Course_Code, 6)
WHERE     (Starting_Date IS NULL)

Starting_Date has a datatype of smalldatetime
Course_Code has a dataype of nvarchar
Avatar of ViceroyFizzlebottom
ViceroyFizzlebottom
Flag of United States of America image

Try:

Starting_Date = CAST(RIGHT(Course_Code,6) AS SMALLDATETIME)
The other thing that may be going on is if Course_Code does not have at leas 6 characters. You may want to check your string length before making the assignment.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NevSoFly
NevSoFly

ASKER

Thank you