How to convert time which is in GPS format to Loca

2019-07-17 06:59发布

问题:

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