Git Product home page Git Product logo

Comments (4)

NickCraver avatar NickCraver commented on May 13, 2024 1

Merging into #250 - plan is to solve this in a central way.

from opserver.

NickCraver avatar NickCraver commented on May 13, 2024

The trick here is that SQL server is not time-zone aware here (or pretty much anywhere). So I have to do a date difference to something. Is your web server running in the same time zone as your SQL server? If that's common then I can just compare to local date time which covers the most cases we can.

And just for my own curiosity, why not run your servers on UTC time? At Stack we can't imagine the chaos of global data with non-standardized time...so I'm very curious when I come across this.

from opserver.

stijnherreman avatar stijnherreman commented on May 13, 2024

The web server is in the same timezone as the SQL server. They're not my servers btw, if they were then they would be on UTC :)

The reason they're not on UTC is that years ago, someone decided they should be in the local time zone. And I can't even imagine how much stuff would break if the time zone was changed.

Perhaps a call to SYSDATETIMEOFFSET() could be cached and utilised to handle this?

from opserver.

kchenery avatar kchenery commented on May 13, 2024

You could convert the time to UTC with something like this (using connect_time as an example):

SELECT  connect_time,
        DATEADD(MINUTE, DATEDIFF(MINUTE, GETDATE(), GETUTCDATE()), connect_time)    AS connect_time_utc
FROM sys.dm_exec_connections

That will work on versions earlier than SQL 2008 too. Where it falls down is the fact that during a daylight savings change it will potentially report an incorrect UTC value.

from opserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.