Sql 随机生成日期时间
时间:2021-07-01 10:21:17
帮助过:2人阅读
DECLARE @dt1 DATETIME,
@dt2 DATETIME,
@a BIGINT,
@b BIGINT
2 SET @dt1=‘2010-01-01‘--开始日期
3 SET @dt2=‘2010-06-30‘--结束日期
4
5 SELECT @a=CAST(
@dt1 AS BIGINT),
@b=CAST(
@dt2-@dt1 AS BIGINT)
6
7 SELECT CAST(
ABS(CHECKSUM(
newID()))
%@b+@a AS DATETIME)
+RAND()
AS 日期
Sql 随机生成日期时间
标签: