如何在 SQL Server 中将 bigint(UNIX 时间戳)转换为日期时间?
问题描述:
如何在 SQL Server 中将 UNIX 时间戳 (bigint) 转换为 DateTime?
How can I convert UNIX timestamp (bigint) to DateTime in SQL Server?
答
这对我有用:
Select
dateadd(S, [unixtime], '1970-01-01')
From [Table]
如果有人想知道为什么 1970-01-01,这被称为 大纪元时间.
In case any one wonders why 1970-01-01, This is called Epoch time.
以下是维基百科的引述:
Below is a quote from Wikipedia:
自 1970 年 1 月 1 日星期四 00:00:00 协调世界时 (UTC) 起经过的秒数,[1][注 1] 不计算闰秒.
The number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970,[1][note 1] not counting leap seconds.