How to convert time which is in GPS format to Local time format in SQL?

主宰稳场 提交于 2020-02-04 14:33:18

问题


This is the data packet which was received from android mobile to my server.

  $|351746051743568|12.9399604|77.6257631|0.0|1392979784822|1|#

In which following is the time which is received from the device: 1392979784822. Since this is in GPS format, I tried to convert into local format in SQL and failed. Please guide me in this issue.


回答1:


Looks like unix/epoch time in millisecs?

declare @x bigint = 1392979784822
declare @msin1day bigint = 3600 * 24 * 1000

select dateadd(ms, @x % @msin1day, dateadd(day, @x / @msin1day, '19700101'))

(No column name)
2014-02-21 10:49:44.823


来源:https://stackoverflow.com/questions/21936148/how-to-convert-time-which-is-in-gps-format-to-local-time-format-in-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!