日期:2014-05-18 浏览次数:20552 次
declare @a bigint,@b int,@c int set @a = 1133768062703 --整数型值(1970年到现在的耗秒数) set @b = @a/(24*60*60*1000) set @c = @a%(24*60*60*1000) select dateadd(dd,@b,dateadd(ms,@c,'1970-01-01'))
------解决方案--------------------
2007-10-16 11:32:38 在用sqlserver取应是1192534358000
select (1192505558687-1192534358000)/60/60/1000 ---相差小时数7.99980916666600
--取数
declare @a bigint,@b datetime,@c datetime
select @a=0,@b='1970-01-01',@c='1970-01-01 11:32:38'
while @b<'2007-10-16 11:32:38'
begin
select @a=@a+datediff(ms,@b,@c)
select @b=@c
set @c=dateadd(dd,1,@c)
end
select @a
--用你的方法验证
declare @a bigint,@b int,@c int
set @a = 1192534358000 --整数型值(1970年到现在的耗秒数)
set @b = @a/(24*60*60*1000)
set @c = @a%(24*60*60*1000)
select dateadd(dd,@b,dateadd(ms,@c,'1970-01-01 0:0:0'))
-----------------------
2007-10-16 11:32:38.000