This SQL uses CHECKSUM(NEWID()) so a unique number is generated.ĭECLARE DATETIME = DATEADD(MINUTE, 5, DATEADD(MILLISECOND, ABS(CHECKSUM(NEWID())) % ( 1 + DATEDIFF(MILLISECOND, generates a date and time between now and the next 5 minutes. The majority of SQL I’ve found on internet uses the RAND function, however, the RAND function does not return a unique result per row in a SELECT statement. The following SQL allows you to generate a random date between two values.