Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Wrong result when comparing two numbers

Hello,

I'm quite new to qlikview and I have a strange result in my script

I try to compare two numbers in an "if" statement but I don't go inside the condition even if the condition seems true :

My first variable

TempMaxDate:

  LOAD

    Max (_comptaTimeStamp)as MaxDate

  from $(vQVDPath)DATA_COMPTA.qvd (qvd);

  

  Let vMaxQVDdate = Peek('MaxDate',0,'TempMaxDate');

  Drop table TempMaxDate;

My second variable

Let vFileDate = num(date#(FileTime('$(file)'),'DD/MM/YYYY hh:mm:ss[.fff]'));

When I debug my code I get

screenshot.10.jpg

screenshot.11.jpg

But I don't enter in the if statement

Any Idea ?

Thank you

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

IF vFileDate > vMaxQVDDate THEN

IMHO, using dollar sign expansion just adds potential issues with number literal formatting here (e.g. decimal separator needs to be a point for a constant number used in the script or expression). And using an implicit string interpretation / string comparison doesn't make it easier.

It should then also be enough to use

Let vFileDate = FileTime('$(file)');

View solution in original post

7 Replies
sunny_talwar

Does this make any difference (not adding Num() function)?

If $(vFileDate) > $(vMaxQVDDate) then

         .....

Not applicable
Author

I get this message

screenshot.12.jpg

sunny_talwar

How about this? Putting the expression within single quotes

If '$(vFileDate)' > '$(vMaxQVDDate)' then

Not applicable
Author

Yeah !

It worked, thank you very much Sunny, Even if I don't understand why my first try was wrong ...

If I understand I'm comparing two strings with your method ?

sunny_talwar

To tell you the truth, I don't know what it's doing. May be someone else can guide us here

swuehl
MVP
MVP

Try

IF vFileDate > vMaxQVDDate THEN

IMHO, using dollar sign expansion just adds potential issues with number literal formatting here (e.g. decimal separator needs to be a point for a constant number used in the script or expression). And using an implicit string interpretation / string comparison doesn't make it easier.

It should then also be enough to use

Let vFileDate = FileTime('$(file)');

Not applicable
Author

Hello Stefan and thank you for your answer, you're right !

I removed the $ and everything is ok even with Let vFileDate = FileTime('$(file)');

Thank' again