snippetsqlMinor
Convert TimeStamp In dm_os_ring_buffers
Viewed 0 times
convertdm_os_ring_bufferstimestamp
Problem
I see this conversion a lot when trying to convert this to a legitimate time:
I get the error:
Arithmetic overflow error converting expression to data type int.
What's the correct formula for converting this?
Answer:ms_ticks
SELECT DATEADD (ms, -1 * ((s.cpu_ticks) - r.[timestamp]), GETDATE())
FROM sys.dm_os_ring_buffers r
CROSS JOIN sys.dm_os_sys_info sI get the error:
Arithmetic overflow error converting expression to data type int.
What's the correct formula for converting this?
Answer:ms_ticks
Solution
See the SQL Server 2008 calculation in this article. It applies to 2012, 2014 and 2016 too.
cpu_ticks is what was used in SQL Server 2005.
cpu_ticks is what was used in SQL Server 2005.
declare @ts_now bigint
select @ts_now = ms_ticks from
sys.dm_os_sys_info
select record_id, dateadd (ms, (y.[timestamp] -@ts_now), GetDate())
...Code Snippets
declare @ts_now bigint
select @ts_now = ms_ticks from
sys.dm_os_sys_info
select record_id, dateadd (ms, (y.[timestamp] -@ts_now), GetDate())
...Context
StackExchange Database Administrators Q#156913, answer score: 8
Revisions (0)
No revisions yet.