I am trying to convert a date to datetime but am getting errors. The datatype I’m converting from is (float,null) and I’d like to convert it to DATETIME.
The first line of this code works fine, but I get this error on the second line:
Arithmetic overflow error converting expression to data type datetime.
CAST(CAST( rnwl_efctv_dt AS INT) AS char(8)),
CAST(CAST( rnwl_efctv_dt AS INT) AS DATETIME),
you need to convert to char first because converting to int adds those days to 1900-01-01
here are some examples
1900-01-06 00:00:00.000
blows up, because you can’t add 20100101 days to 1900-01-01..you go above the limit
convert to char first