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

Same date value, different weekday values

Hi all,

i recently came across with a problem within Qlik sense.

with the script below, i got 2 different weekday returned

SET FirstWeekDay=6;

LET vQVD_TS = '15/02/2018';
LET vQVD_TS1 = DATE(TODAY()-1);

LET vDAY=NUM(WEEKDAY($(vQVD_TS)))&'.'&WEEKDAY($(vQVD_TS)); //6.Sat
LET vDAY1=NUM(WEEKDAY(TODAY()-1))&'.'&WEEKDAY(TODAY()-1); //4.Thu
LET vDAY2=NUM(WEEKDAY($(vQVD_TS1)))&'.'&WEEKDAY($(vQVD_TS1)); //6.Sat
LET vDAY3=NUM(WEEKDAY('15/02/2018'))&'.'&WEEKDAY('15/02/2018'); //4.Thu

i tried all sorts of date convertion, nothing woked. It seems to me that if a date value is in variable, weekday will not wok properly

i wonder if it is a bug or i was doing something wrong here.

Hope someone can shed some light for me.

thanks in advance.

2 Replies
tresesco
MVP
MVP

I guess, it's about $ expansion issue and not a bug. Try using any date function while defining the varibale like:

LET vQVD_TS = MakeDate(2018,2,15)          // instead if '15/02/2018';

It should work fine then.


LET vQVD_TS = '15/02/2018';    // this doesn't work potentially because, with $-expansion, '/' could be interpreted as division operator. And that gives you a different unwanted number.

mydearleo
Contributor II
Contributor II
Author

Thanks Tresesco, i think i worked it out. i believe you are right, it is to do with $ expansion.

however makedate did not work, instead, i put single quotes around $(vQVD_TS) and solved the problem.