|
Hi I have a stored procedure that is trying to pass datetime parameters @StartDate and @EndDate but when I run the query I get the following Error.... Arithmetic overflow error converting expression to data type datetime. Below is my Stored Procedure.... I should note that The CENSUSDATEKEY field is an INT type I need to convert it to Datetime type
(comments are locked)
|
|
... CAST(CAST(CensusDateKey AS CHAR(8)) AS DATETIME) >= @StartDate AND CAST(CAST(CensusDateKey AS CHAR(8)) AS DATETIME) <= @EndDate ... should fix it. Awesome that worked perfectly
Oct 12 '12 at 03:39 PM
tombiernacki
(comments are locked)
|
|
You need to be sure that there is valid data in the CensusDateKey column. One way of doing it is to execute a query using ISDATE function, something like This will give you any invalid data. Not to mention, storing date data in other data types always gives pain.
(comments are locked)
|


So what values are in the CensusDateKey field?
The CensusDateKey has int date values like 20090101