2
Vote

ASTrace: time shift

description

Hello,
ASTrace runs on the same server as AS being traced and SQL where log table is.
StartTime and CurrentTime have 2 hours shift to system clock.
Same events in Profiler (simultaneously traced) have no time shift.
What can it actually be?
 
Thank you in advance!
Michael.

comments

koehlerb wrote Mar 15, 2011 at 9:07 PM

The problem looks to be that the TraceServer returns UTC time. No good workaround, though you can correct using SQL.
e.g.
DECLARE @utcOffset int = (SELECT CAST(GETDATE()-GETUTCDATE() as float)*24)
SELECT DateAdd(hour,@utcOffset,StartTime) FROM dbo.ASTrace

This does not account for changes in daylight savings time.

What is needed is something like the dataReader
System.Data.IDataReader dataReader;
...
value = dataReader.GetValue(counter);
if (value != null)
                    {   //time is in UTC, convert to localtime
                        if (value.GetType() == typeof(DateTime))
                        {
                            value = DateTime.SpecifyKind((DateTime)value, DateTimeKind.Utc).ToLocalTime();

wrote Feb 21, 2013 at 11:34 PM