Get difference in minutes using epoch time in SQL Server

xfb7svmp  于 2023-06-28  发布在  SQL Server
关注(0)|答案(1)|浏览(166)

I am using automation tool in that I am getting now time in epoch format. There is no time. I am getting one is start of process time and other end process time

  1. Process start time : 1505815205159
  2. Process end time : 1505816321742

I need the difference of these two epoch times in minutes in SQL Server - is there a way to do this?

tp5buhyn

tp5buhyn1#

UPDATE :

  1. DECLARE @duration decimal (18,2)
  2. SET @duration = 1505816321742 - 1505815205159
  3. SELECT CONVERT(varchar, DATEADD(s, @duration * 1000, 0), 114)

Result : 09:56:40:000

DateAdd Intervals :

  1. year, yyyy, yy = Year
  2. quarter, qq, q = Quarter
  3. month, mm, m = month
  4. dayofyear = Day of the year
  5. day, dy, y = Day
  6. week, ww, wk = Week
  7. weekday, dw, w = Weekday
  8. hour, hh = hour
  9. minute, mi, n = Minute
  10. second, ss, s = Second
  11. millisecond, ms = Millisecond
展开查看全部

相关问题