Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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');
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.
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.
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,
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.
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.
Hi,
Suggested by @AustinSpivey and Oleg_Troyansky i feel these are the option you can explore, in addition ill raise a ticket & get my time zone fixed for my tenant .
Resolved, You are awesome my friend! Thank You.
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)'