Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Arithmetic overflow error

$
0
0

Hi all,

The below is suppose to generate random dates but I receive the following error:

 
Msg 8115, Level 16, State 2, Line 7
Arithmetic overflow error converting expression to data type datetime.

SQL Below - if is this happening?

DECLARE
@MinDate INT, @MaxDate INT;
DECLARE
 @RANGE INT = DATEDIFF(DD, @MinDate, @MaxDate);
SET @MaxDate =20141212
SET @MinDate = 20140101
SELECT CONVERT(DATE, DATEADD(DD, ROUND(RAND(CAST(NEWID() AS VARBINARY)) * @RANGE,0,-1), @MinDate));


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>