我在 sql 表中有一个将 DateTime.Ticks 值保存为 bigint 的列。现在,我想在 sql 查询中将此 bigint 值转换为 datetime 可以帮助我继续吗?
谢谢
看到这个答案:
Declare @TickValue bigint
Declare @Days float
Set @TickValue = 634024345696365272
Select @Days = @TickValue * POWER(10.00000000000,-7) / 60 / 60 / 24
Select DATEADD(d, Cast(@Days As int), Cast('0001-01-01' As DATE))
+ Cast( (@Days - FLOOR(@Days)) As DateTime)