Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arithmetic overflow error converting expression to data type datetime

This select statement gives me the arithmetic error message:

SELECT CAST(FLOOR((CAST(LeftDate AS DECIMAL(12,5)))) AS DATETIME), LeftDate 
FROM Table
WHERE LeftDate > '2008-12-31'

While this one works:

SELECT CAST(FLOOR((CAST(LeftDate AS DECIMAL(12,5)))) AS DATETIME), LeftDate 
FROM Table
WHERE LeftDate < '2008-12-31'

Could there be something wrong with the data (I've checked for null values, and there are none)?

like image 847
oekstrem Avatar asked Mar 11 '09 09:03

oekstrem


1 Answers

Found the problem to be when a date was set to 9999-12-31, probably to big for the decimal to handle. Changed from decimal to float, and every thing is working like a charm.

like image 125
oekstrem Avatar answered Sep 20 '22 00:09

oekstrem