Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
flavioamcoutinho
Contributor
Contributor

Dates

How do I add the number of days to a certain date that is present in a table and when I find it I set it to 0 and so on?

3 Replies
dplr-rn
Partner - Master III
Partner - Master III

to add days just do + to your date field and format the output according to what you need e.g. OrderDate+1
Not clear what you mean (second part)
flavioamcoutinho
Contributor
Contributor
Author

on this code what's wrong? 

 

let vDiaAcidente = 0;
let vDateYearStart = YearStart(Today());
let vDateYearEnd = Today();

let numeroInicio = Num(Date#(vDateYearStart, 'DD/MM/YYYY')); //dia para numero
let numeroFim = Num(Date#(vDateYearEnd, 'DD/MM/YYYY')); //dia para numero

let nRows = NoOfRows('Controlo') - 4;

trace $(vDateYearStart) - $(vDateYearEnd)
$(numeroInicio) - $(numeroFim);

For i = numeroInicio to numeroFim
for j = 0 to $(nRows)
let vData = Peek('Data',$(j));
// Trace $(vData);
If (i) = vData then
vDiaAcidente = 0;
Else
vDiaAcidente = vDiaAcidente + 1;
end if
// trace $(vDiaAcidentes);
next i;
next j;

dplr-rn
Partner - Master III
Partner - Master III

not entirely clear what you are trying to do. but i do see the for loops ended wrongly

you have mentioned 'next i' before 'next j' should be other way around