Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Dariobueno
Contributor
Contributor

Subtração de datas qlik sense / Date subtraction qlik sense

Bom dia!

 

Precisava de uma força para realizar a subtração de uma data pela outra e depois a divisão pelo total, para conseguir o a média de tempo.

também gostaria de realizar esse calculo e condicionar o resultado que esteja dentro de um horário especifico. 

Campos: dt_alta, dt_entrada e nr_atendimentos

Google tranlation

It needed a force to perform the subtraction of one date by the other and then the division by the total, to obtain the time average.

I would also like to perform this calculation and condition the result that is within a specific time.

Fields: dt_alta, dt_entrada and nr_atendimentos

1 Reply
QFabian
Specialist III
Specialist III

Hi @Dariobueno , i made this example, check if it works for you :

example script


//Check your date format and separator
Aux:
LOAD * INLINE [
dt_alta, dt_entrada, nr_atendimento
29-03-2022 08:59:59, 12-03-2022, 1
01-03-2022 09:00:00, 12-02-2022, 2
29-03-2022 12:00:00 , 01-01-2022, 3
29-03-2022 18:00:00, 27-03-2022, 4
29-03-2022 20:00:00, 27-03-2022, 5
29-03-2022 20:00:00, 26-03-2022, 6
];

Data:
Load
dt_alta as Date_Alta,
frac(dt_alta) as Hour_Alta,
if(frac(dt_alta)>=.375 and frac(dt_alta)<= .75, 1,0) as Hour_AltaRange, // .375 9:00 .75 18:00 // to create a new field for labor hour
dt_entrada as Date_Entrada,
nr_atendimento
Resident Aux;
drop table Aux;

table chart output :

QFabian_1-1648583953701.png

qvw attached below

 

QFabian