SQL Date Parsing Error

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:
[code]year(date_column)[/code]
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:
[code]year(cast(date_column as varchar(8)))[/code]

 


Steven

Hi Brad - I am very new to parsing data of any kind much less the AS400 system. I am attempting to parse our AS400 system and can't seem to get a stating point. There is a particular frame in AS400 that I would like to drop name, employee nos, and date out of and into an Excel spreadsheet/workbook. Could I get a copy of your parsing code so I can see how it's done?

Thank you in advance for your time. Steve

Site Updates

Entry Comments

Entries Search