Get difference in minutes using epoch time in SQL Server

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

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

Process start time : 1505815205159
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 :

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

Result : 09:56:40:000

DateAdd Intervals :

year, yyyy, yy = Year
quarter, qq, q = Quarter
month, mm, m = month
dayofyear = Day of the year
day, dy, y = Day
week, ww, wk = Week
weekday, dw, w = Weekday
hour, hh = hour
minute, mi, n = Minute
second, ss, s = Second
millisecond, ms = Millisecond

相关问题