Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Carlinhos02
Contributor III
Contributor III

FUSO HORARIO US

Pessoal, boa tarde. Tenho um painel em tempo real, porem quando passa das 22:00  aqui o cloud, ele me traz os valores do próximo dia, por exemplo, hoje é dia 16 e a meta é de 100 Reais, quando chega as 22:01 horas ele me traz a meta do dia 17. ou seja aparece la que a meta do dia 16 é agora 200 Reais. queria corrigir isso. (meu fuso horario é o de brasilia)visto que meu Cloud é do servidor US.

Como faço isso na extração já que meu painel é em tempo real

 SELECT
DIA,
COD_CENTRO,
METAVALOR
FROM
(SELECT A.DIA, '1005' COD_CENTRO, A.METAPCEASA METAVALOR, B.DIASFATCEASA DIASFAT
FROM AAAA.VVWW_META_LOJAS A, AAAA.VVWW_DIAS_FATURAVEIS B WHERE A.DIA = B.DIA
UNION ALL
SELECT A.DIA, '1006' COD_CENTRO, A.METAPCAMARELA METAVALOR, B.DIASFATCAMARELA DIASFAT
FROM AAAA.VVWW_META_LOJAS A, AAAA.VVWW_DIAS_FATURAVEIS B WHERE A.DIA = B.DIA
UNION ALL
SELECT A.DIA, '1007' COD_CENTRO, A.METAPIMBIRIBEIRA METAVALOR, B.DIASFATIMBIRIBEIRA DIASFAT
FROM AAAA.VVWW_META_LOJAS A, AAAA.VVWW_DIAS_FATURAVEIS B WHERE A.DIA = B.DIA
UNION ALL
SELECT A.DIA, '2001' COD_CENTRO, A.METAPLOJAO METAVALOR, B.DIASFATLOJAO DIASFAT
FROM AAAA.VVWW_META_LOJAS A, AAAA.VVWW_DIAS_FATURAVEIS B WHERE A.DIA = B.DIA)
WHERE DIA >= TO_CHAR(TRUNC((SYSDATE)-1),'YYYYMMDD');

1 Solution

Accepted Solutions
AustinSpivey
Partner - Creator
Partner - Creator

Not sure if I'm understanding this correctly or not but it seems like you'd be able to use some logic in Qlik to add an offset to your SQL Where clause so that you're comparing your [DIA] fields relative to the current timezone-adjusted date.

AustinSpivey_0-1700588842681.png

You could try using an If-Then statement like the one above to update an offset variable for use in the SQL Where clause.

If DayStart(Now(1) + 1) - Now(1) <= (2/24) Then

^This part checks to see if the current time (in your Qlik Cloud region) is within 2 hours of the beginning of the next day. If it is, then we set our vDayOffset variable to 1. Otherwise, we set the  vDayOffset variable to 2.

Then in the SQL Where clause, we use our dollar sign-expanded  vDayOffset variable to offset the SYSDATE keyword, which is presumably what is returning a datetime value for the current time in Brasilia timezone.

Austin Spivey | Principal Consultant @ Arc Analytics
ArcAnalytics.us | Add me on LinkedIn

View solution in original post

9 Replies
Carlinhos02
Contributor III
Contributor III
Author

@Oleg_Troyansky

@Austin Spivey

@23mageste

@@40Witney_Arau

@28paulinok14

@02ajaykakkar93

@RayRay81

Carlinhos02
Contributor III
Contributor III
Author

Carlinhos02
Contributor III
Contributor III
Author

@AHH 

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

This is a bit complex...

If you just needed to correct the last WHERE condition, you could subtract 2 hours (2/24 or 1/12) from the timestamp, and that would move your "midnight" by two hours, as desired. 

However, it looks like the date is already pre-calculated and stored in all source tables in the field DIA, and that date was calculated based on the US time zone (CST or EST?) These fields would need to be recalculated in your local time zone, before you could use them for joining.

So, I'd say that you have 2 options:

1. If you have full control over your source data, modify the source data and calculate all the date fields with the correct time zone.

2. Otherwise, you'd need to do everything manually in Qlik:

- Load all relevant source tables indivually

- Convert the timestamps to the local time zone in all timestamp fields, and calculate the new (local) Date field values

- Then, you can join these tables based on the newly calculated Date values.

Cheers,

Carlinhos02
Contributor III
Contributor III
Author

AustinSpivey
Partner - Creator
Partner - Creator

Not sure if I'm understanding this correctly or not but it seems like you'd be able to use some logic in Qlik to add an offset to your SQL Where clause so that you're comparing your [DIA] fields relative to the current timezone-adjusted date.

AustinSpivey_0-1700588842681.png

You could try using an If-Then statement like the one above to update an offset variable for use in the SQL Where clause.

If DayStart(Now(1) + 1) - Now(1) <= (2/24) Then

^This part checks to see if the current time (in your Qlik Cloud region) is within 2 hours of the beginning of the next day. If it is, then we set our vDayOffset variable to 1. Otherwise, we set the  vDayOffset variable to 2.

Then in the SQL Where clause, we use our dollar sign-expanded  vDayOffset variable to offset the SYSDATE keyword, which is presumably what is returning a datetime value for the current time in Brasilia timezone.

Austin Spivey | Principal Consultant @ Arc Analytics
ArcAnalytics.us | Add me on LinkedIn
ajaykakkar93
Specialist III
Specialist III

Hi,

Suggested by @AustinSpivey and   i feel these are the option you can explore, in addition ill raise a ticket & get my time zone fixed for my tenant .

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

Carlinhos02
Contributor III
Contributor III
Author

Resolved, You are awesome my friend! Thank You.
therealdees
Creator III
Creator III

Fala, Carlinhos

 

Tava abrindo o forum pra fazer um post reclamando disso e vi sua mensagem, kkkk

 

Tenho sofrido com isso também e já pesquisei sobre o assunto e existe uma solução mais simples, você pode usar:

ConvertToLocalTime(UTC(), 'UTC-03:00')

 

A função traz o horário da timezone de SP (não sei ao certo outros estados), mas não funciona bem a nível de gráfico, porque utiliza processamento em tempo real e faz o painel ficar bugado, travando, piscando, etc., se você utilizar em muitos objetos, por exemplo em um item mestre

 

Como você quer utilizar a nível de script, você pode adicionar o valor em uma variável e calcular a variável nas clausulas de Where, ex:

 

LET vHoje = ConvertToLocalTime(UTC(), 'UTC-03:00');

 

Temp:

LOAD *

From x

Where date = '$(vHoje)'