简体   繁体   English

Power BI 中的时区更改

[英]Timezone changes in Power BI

We have a team that currently resides in the US and Poland .我们有一支目前居住在USPoland的团队。 Due to time changes, the " excused " login time is incorrect for Krakow because some analysts start around 11 pm Poland time , and the system picks up that they logged in at 12am the next day US time.由于时间变化, Krakow的“ excused ”登录时间不正确,因为一些分析师在11 pm Poland time左右开始,系统显示他们在美国时间第二天上午12am点登录。

This is currently what I have written:这是我目前写的:

  SELECT 
         UPPER([UTL_REFERENCE]) as userid,
         CONVERT(date, schedule. dia) as date,
         schedule.dia as scheduled,
         schedule.Excused 
    FROM 
    (
       SELECT 
          MIN( HORT_DATE + CAST(cast(HORT_HEURE_DEBUT as time) as datetime)) as dia, 
          CONVERT(date, HORT_DATE) as the_day, 
          HORT_XRF_REP_SEQUENCE,
          Excused = 
           CASE 
             WHEN (HORT_CODE_ACTIVITE = 13 and HORT_ID_RESTRICTION = 32) then 1 else 0 
           end 
        FROM [CWFM].[dbo].[CalHorairesxJourxPrepose] chj
        where  
          HORT_CODE_ACTIVITE IN (4, 13,17) and 
          HORT_DATE > '2019-01-01 00:00:00'
        group by CONVERT(date,HORT_DATE), HORT_XRF_REP_SEQUENCE,
           CASE 
             WHEN (HORT_CODE_ACTIVITE = 13 and HORT_ID_RESTRICTION = 32) then 1 
             else 0 
           end 
     ) schedule 

inner join [CWFM].[dbo].CalPreposes cp 
    on cp.REP_SEQUENCE = schedule.HORT_XRF_REP_SEQUENCE
inner join [CWFM].[dbo].[CalProfilUtilisateurs] cpu 
    on cp.REP_SEQUENCE = cpu.[UTL_XRF_REP_SEQUENCE]
where cp.REP_ACTIF = 1

The first thing to remember is that the local-times are not mixed up:首先要记住的是当地时间没有混淆:

  1. Convert all time stamps from local-time-stamps to UTC time, then you can compare the different time-stamps simple in generalized/normalized form.将所有时间戳从本地时间戳转换为 UTC 时间,然后您可以简单地以广义/标准化形式比较不同的时间戳。
  2. The database -server/-service could also use a different time-zone in the setup.数据库 -server/-service 也可以在设置中使用不同的时区。

This is a good articel for your problem:这是解决您问题的好文章:

https://www.fourmoo.com/2017/10/03/power-bi-did-you-know-all-power-bi-services-servers-are-in-utc-now-how-to-handle-it-for-dates-times/ https://www.fourmoo.com/2017/10/03/power-bi-did-you-know-all-power-bi-services-servers-are-in-utc-now-how-to-handle-它的日期时间/

So you need to add to every time-stamp the correct time-zone - eg:因此,您需要在每个时间戳中添加正确的时区 - 例如:

DateTime.AddZone([Date],-12)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM