代码之家  ›  专栏  ›  技术社区  ›  slthomason

在查询中使用本地时间

  •  1
  • slthomason  · 技术社区  · 6 年前

    我希望使用本地时间而不是UTC显示此查询的结果:

    union * 
    |  
    order by timestamp desc
    

    我怎样才能让它显示当地时间?我知道有些变化 dateadd(timestamp - 7h) 但我想不通。

    2 回复  |  直到 6 年前
        1
  •  1
  •   Joey Cai    6 年前

    由于所有日期时间都是用UTC表示的,因此将它们转换为本地时区通常很有用。为了简单地查看数据,我们可以 使用datetime math添加列以添加或减去所需的小时数 . 你可以参考这个 article 更多细节。

    union * 
    | extend localTimestamp = timestamp - 7h
    | order by localTimestamp desc 
    

    enter image description here

        2
  •  0
  •   GerardBeckerleg    6 年前

    现在还可以通过UI设置将所有报告默认为本地时间,这有助于您考虑夏时制。

    enter image description here

    enter image description here