将Epoch转换为DateTime SQL Server

编程入门 行业动态 更新时间:2024-10-26 11:25:44
本文介绍了将Epoch转换为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

本文发布于:2023-11-04 12:10:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   Epoch   DateTime   Server   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!