SQL Date Parsing Error
Posted by
Brad Wood
Sep 30, 2008 23:38:00 UTC
I am writing some SQL to pull data from our AS400 here at work. I was getting the error "Arithmetic overflow error converting expression to data type datetime." from the following code where date_column contained a date formatted like 20080930:
year(date_column)
At first, I thought there was some bad data in the column. It turns out, the datatype was int as opposed to varchar like I had assumed. This fixed it:
year(cast(date_column as varchar(8)))
Tags: SQL