Question : time as number?

When SQL internals stores time as bigint, is it possible to interpret the correct time? What algorithm is used for that..

example:
SELECT top 1 TIMEint.value('(//Record/@time)[1]','varchar(15)')  
FROM (SELECT CAST([record] AS XML)
FROM [sys].[dm_os_ring_buffers]) AS xyz(TIMEint)

thanks

Answer : time as number?

The more I think on it and what I know of timestamp columns in MS SQL, there is probably not some easy formula as the first MVP asserts but for my system the first proposed formula brings back seemingly realistic values.

select i.ms_ticks, b.timestamp
    , DATEADD(ms, b.timestamp - i.ms_ticks, getdate()) as recordtime
from sys.dm_os_ring_buffers b
cross join sys.dm_os_sys_info i


Notice there is a timestamp column directly in the buffers table so you don't need to go through the XML to get that value.


Random Solutions  
 
programming4us programming4us