Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math overflow error converting to DATETIME from large textfile

Status
Not open for further replies.
Oct 7, 2003
4
US
I have a file of approximately a million records that was imported from a mainframe file. I'm trying to convert a field that's in a format like 20070530 - ie, YYYYMMDD, in order to be able to do date calculations on it. I don't care how it looks, I just care if internally it's a real datetime field. I'm trying to insert it into a new file using CONVERT(datetime,date_billed,101), but I keep getting a math overflow error. Is this because of the number of records, or what? The record length is only 50 characters.
 
That format YYYYMMDD is the perfect format to use for sql server. I would suggest you remove the ,101 from your convert statement.

Also, you may want to look into the IsDate function. It returns 1 if you have a valid date, otherwise it returns 0.



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I've tried the above suggestions, and still keep getting the overflow error. Could it have anything to do with the number of records? Does SQL Server 2005 have some sort processing limitation?
 
Do you have this data in a table already?

Also, double check the data type you are trying to import in to. There are 2 data types that can store data. There's the DATETIME data type, but there's also a SmallDateTime. The SmallDateTime data type has a smaller range, so you could be having problems with that.

Take a look at this: faq183-6419

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Hooray, it finally worked, using style 120:

INSERT INTO CISMast
([Out_date_Billed])

select
convert(datetime,out_date_billed,120)
from cis_newfile
where isdate(out_date_billed) = 1

Thanks, guess it was just a matter of finding the right combo of everything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top