Conversion timestamp and SqlServer solve common format

 

 First, determine the accuracy of the time stamp, and then converted according to the following method

/ ********************************************** timestamp conversion (second) **********************************************/

- General time to a timestamp (in seconds)
the SELECT the DATEDIFF (the SS, '1970-1-1 00: 00: 00', GETUTCDATE ())

- millisecond time stamp of Common (s)
the SELECT the DATEADD (the SS, 1447842393, '1970-1-1 08:00:00')

/ ********************************************** timestamp conversion (ms) ********************************************** /

- General time to a timestamp (in milliseconds)
the DECLARE @ADATE DATETIME
the SET @ADATE = GETUTCDATE ()
the SELECT the CONVERT (BIGINT, the DATEDIFF (MI, '1970-01-01 00: 00: 00.000', @ADATE)) * 60000 + DATEPART (S, @ ADATE) * 1000 + DATEPART (MS, @ADATE)

- timestamp of Common milliseconds (ms)
the DECLARE @UNIXTIME BIGINT
the SET = 1447842306000 @UNIXTIME
the SELECT the DATEADD (the MS,% @ unixtime 60000, the DATEADD (MI, @ unixtime / 60000, '1970-01-01 08: 00: 00.000 '))

Guess you like

Origin www.cnblogs.com/Damon-LLJ/p/11959077.html