将Epoch转换为DateTime SQL Server [英] Convert Epoch to DateTime SQL Server
问题描述
对不起,我的冠军中奖了.
Apologies my cap broke mid title.
我遇到以下问题:
dateadd(S, [unixtime], '1970-01-01')
在SQL Server中将纪元转换为 datetime
,但是收到以下错误:
to convert epoch to datetime
in SQL Server, but received the following error:
将表达式转换为数据类型int的算术溢出错误.
Arithmetic overflow error converting expression to data type int.
很明显,这意味着对于 int
而言,纪元太大了吗?即使此代码以前已经起作用过;奇怪的是.有没有办法用bigint来称呼它?
Obviously it means the epoch is too big for int
? even though this code has worked previously; bizarrely. is there a way to call this with bigint?
例如时代:
1440753397054
而且我认为该限制为10位数字,所以可以选择吗?
and I believe the limit is 10 digits, so an alternative?
推荐答案
您的时间戳以秒为单位.尝试将其除以1000,我相信它会起作用.
Your timestamp is in milliseconds. Try dividing it by 1000 and I'm sure it will work.
1440753397054/1000 = 1440753397,054
对应于(假设GMT):
1440753397054 / 1000 = 1440753397,054
corresponds to (assuming GMT):
周五,格林尼治标准时间2015年8月28日09:16:37
这篇关于将Epoch转换为DateTime SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!