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

How to create a variable for a special date

I need to read a table within the last week, I am looking for something like:

LET vStartdate = '01.05.2015';

LET vEnddate = '08.05.2015';

LOAD  CreatedAt WHERE CreatedAt >= $(vStartdate) AND CreatedAt <= '08.05.2015';

---------------------------

Return of terminal was that the error was here:

LOAD  CreatedAt WHERE CreatedAt >= 01.05.2015 AND CreatedAt <= '08.05.2015'

I found this, but I am not sure how to fix it:

The cause is that $(vStartdate) returns a string. The result is that you compare a numeric month value (because of the >= operator) with a string value. By changing the variable so that it return a number it's possible to use the >= and <= operators. To make the first part of the chart expression work I changed the modifier so it works with the number value of the variable.


Please help. Thank you in advance.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try these:

LET vStartdate = num(date#('01.05.2015','DD-MM-YYYY);

LET vEnddate = num(date#('08.05.2015','DD-MM-YYYY);

Or

LET vStartdate = num(makedate(2015,5,1));

LET vEnddate = num(makedate(2015,5,8));


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

Try these:

LET vStartdate = num(date#('01.05.2015','DD-MM-YYYY);

LET vEnddate = num(date#('08.05.2015','DD-MM-YYYY);

Or

LET vStartdate = num(makedate(2015,5,1));

LET vEnddate = num(makedate(2015,5,8));


talk is cheap, supply exceeds demand
Not applicable
Author

Wow that was fast!

2nd worked. Perfect. Many Thanks.