简体   繁体   中英

Timezone changes in Power BI

We have a team that currently resides in the US and Poland . 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.

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.
  2. The database -server/-service could also use a different time-zone in the setup.

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/

So you need to add to every time-stamp the correct time-zone - eg:

DateTime.AddZone([Date],-12)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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