Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date format error / Sql

I am trying to load incrementing data, with the following statements.

From my initial QVD I extract the max date like so:

Tickets:
LOAD:
....

.....

....

....

.....

....

From test.qvd (qvd);

//Find last Create Date

Last_Create_Date:

LOAD max(date(CreateStamp)) as MaxDate

Resident Tickets;

//Store Max Create Date into Variable

LET Last_Create_Date = peek('MaxDate',0,'Last_Create_Date');

// Delete Tickets Table

DROP Table Tickets;

Then, in my Next load statement I am trying to load WHERE to_date(createdate) > $(Last_Create_Date)

However, its not working, it seems that the Sql is not understanding the format I am sending, because if I change it to WHERE to_date(createdate) > '2017-01-01' It works.

One thing that I noticed, is that if I load the variable into a text field as such =Last_Create_Date, I get the proper date, however, if I load it with $ expansion as =$(Last_Create_Date) I get 0.000192107580... Could it be that this is what Sql is also receiving?

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

This is an interesting catch... when you use a $-sign expansion with a date, it evaluates the expression:

$(4/20/2017) = 4/20/2017 = 9.915716410510659e-5 (a very small number)

The solution is rather simple - enclose the $-sign expansion in single quotes:

WHERE to_date(createdate) > '$(Last_Create_Date)'

This is just one of many cool scripting techniques that Rob Wunderlich is teaching at the Masters Summit for Qlik. Check out if our agenda is right for you.

Cheers,

Oleg Troyansky

Upgrade your Qlik skills with my book QlikView Your Business: An Expert Guide to Business Discovery with QlikView and Qlik Sense

View solution in original post

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

This is an interesting catch... when you use a $-sign expansion with a date, it evaluates the expression:

$(4/20/2017) = 4/20/2017 = 9.915716410510659e-5 (a very small number)

The solution is rather simple - enclose the $-sign expansion in single quotes:

WHERE to_date(createdate) > '$(Last_Create_Date)'

This is just one of many cool scripting techniques that Rob Wunderlich is teaching at the Masters Summit for Qlik. Check out if our agenda is right for you.

Cheers,

Oleg Troyansky

Upgrade your Qlik skills with my book QlikView Your Business: An Expert Guide to Business Discovery with QlikView and Qlik Sense

Not applicable
Author

Thank you very much Oleg, it worked.